RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.content.puzzle.PuzzleDisplay Class Reference

Handles displaying the puzzle. More...

Collaboration diagram for com.runehive.content.puzzle.PuzzleDisplay:

Public Member Functions

boolean click (int button)
 Handles clicking on the puzzle interface.
void open (PuzzleType puzzleType)
 Opens the puzzle interface.
 PuzzleDisplay (Player player)
 Constructs a new PuzzleDisplay.

Package Attributes

int successCount
 The success count.

Private Member Functions

boolean checkAnswer (int button)
 Checks the puzzle answer.
void randomize ()
 Randomize the puzzle.

Private Attributes

int[] options
 The options array.
final Player player
 The player instance.
PuzzleData puzzle
 The puzzle data.
PuzzleType type
 The puzzle type.

Detailed Description

Handles displaying the puzzle.

Author
Daniel

Definition at line 12 of file PuzzleDisplay.java.

Constructor & Destructor Documentation

◆ PuzzleDisplay()

com.runehive.content.puzzle.PuzzleDisplay.PuzzleDisplay ( Player player)

Constructs a new PuzzleDisplay.

Definition at line 29 of file PuzzleDisplay.java.

29 {
30 this.player = player;
31 }

References player.

Member Function Documentation

◆ checkAnswer()

boolean com.runehive.content.puzzle.PuzzleDisplay.checkAnswer ( int button)
private

Checks the puzzle answer.

Definition at line 55 of file PuzzleDisplay.java.

55 {
56 int index = button - 4550;
57 int model = options[index];
58 return model == puzzle.getAnswer();
59 }
val index

References options, and puzzle.

Referenced by click().

Here is the caller graph for this function:

◆ click()

boolean com.runehive.content.puzzle.PuzzleDisplay.click ( int button)

Handles clicking on the puzzle interface.

Definition at line 62 of file PuzzleDisplay.java.

62 {
63 switch (button) {
64 case 4550:
65 case 4551:
66 case 4552:
67 if (checkAnswer(button)) {
68 successCount++;
69 type.onSuccess(player);
70 return true;
71 }
72 successCount = 0;
73 type.onFailure(player);
74 return true;
75 }
76 return false;
77 }

References checkAnswer(), player, successCount, and type.

Here is the call graph for this function:

◆ open()

void com.runehive.content.puzzle.PuzzleDisplay.open ( PuzzleType puzzleType)

Opens the puzzle interface.

Definition at line 40 of file PuzzleDisplay.java.

40 {
41 randomize();
42
43 for (int index = 0; index < 3; index++) {
44 int sequenceModel = puzzle.getSequenceModel(index);
45 int optionModel = options[index];
46 player.send(new SendInterfaceWidget(4545 + index, sequenceModel));
47 player.send(new SendInterfaceWidget(4550 + index, optionModel));
48 }
49
50 type = puzzleType;
51 player.interfaceManager.open(4543);
52 }

References options, player, puzzle, randomize(), and type.

Referenced by com.runehive.content.bloodmoney.BloodMoneyChest.open().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ randomize()

void com.runehive.content.puzzle.PuzzleDisplay.randomize ( )
private

Randomize the puzzle.

Definition at line 34 of file PuzzleDisplay.java.

34 {
35 this.puzzle = PuzzleData.PUZZLES[(int) (Math.random() * PuzzleData.PUZZLES.length)];
36 this.options = Utility.shuffleArray(puzzle.getOptions());
37 }

References puzzle, com.runehive.content.puzzle.PuzzleData.PUZZLES, and com.runehive.util.Utility.shuffleArray().

Referenced by open().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ options

int [] com.runehive.content.puzzle.PuzzleDisplay.options
private

The options array.

Definition at line 20 of file PuzzleDisplay.java.

Referenced by checkAnswer(), and open().

◆ player

final Player com.runehive.content.puzzle.PuzzleDisplay.player
private

The player instance.

Definition at line 14 of file PuzzleDisplay.java.

Referenced by click(), open(), and PuzzleDisplay().

◆ puzzle

PuzzleData com.runehive.content.puzzle.PuzzleDisplay.puzzle
private

The puzzle data.

Definition at line 17 of file PuzzleDisplay.java.

Referenced by checkAnswer(), open(), and randomize().

◆ successCount

int com.runehive.content.puzzle.PuzzleDisplay.successCount
package

The success count.

Definition at line 26 of file PuzzleDisplay.java.

Referenced by click().

◆ type

PuzzleType com.runehive.content.puzzle.PuzzleDisplay.type
private

The puzzle type.

Definition at line 23 of file PuzzleDisplay.java.

Referenced by click(), and open().


The documentation for this class was generated from the following file: