Class: Infopane

Inherits:
Object
  • Object
show all
Defined in:
lib/lib/user_interface/infopane.rb

Overview

Score, turn and event texts

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeInfopane

Returns a new instance of Infopane.



8
9
10
11
12
13
# File 'lib/lib/user_interface/infopane.rb', line 8

def initialize
  @turn = 0
  @faction = FACTIONS # so that FAC1 will be then the first active faction
  @score = [0, 0]
  @text = 'ready'
end

Instance Attribute Details

#cursor=(value) ⇒ Object (writeonly)

Sets the attribute cursor

Parameters:

  • value

    the value to set the attribute cursor to.



6
7
8
# File 'lib/lib/user_interface/infopane.rb', line 6

def cursor=(value)
  @cursor = value
end

#factionObject (readonly)

Returns the value of attribute faction.



5
6
7
# File 'lib/lib/user_interface/infopane.rb', line 5

def faction
  @faction
end

#text=(value) ⇒ Object (writeonly)

Sets the attribute text

Parameters:

  • value

    the value to set the attribute text to.



6
7
8
# File 'lib/lib/user_interface/infopane.rb', line 6

def text=(value)
  @text = value
end

Instance Method Details

#add_score(to_whom, how_much) ⇒ Object



46
47
48
# File 'lib/lib/user_interface/infopane.rb', line 46

def add_score(to_whom, how_much)
  @score[to_whom] += how_much
end

#drawObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/lib/user_interface/infopane.rb', line 18

def draw
  freeroam_text = ""
  freeroam_text = " (freeroam)" if (@cursor and @cursor.freeroam)

  state = Gosu::Image.from_text(turnscore + freeroam_text, LINE_HEIGHT)
  state.draw(XTEXT, YTEXT, ZTEXT)

  text = Gosu::Image.from_text("#{@text}", LINE_HEIGHT)
  text.draw(XTEXT, (TILESIZE / 2) + YTEXT, ZTEXT)
end

#next_faction!Object

Increment faction counter (modulo count of factions)



36
37
38
39
# File 'lib/lib/user_interface/infopane.rb', line 36

def next_faction!
  @faction += 1
  @faction = 1 if @faction > FACTIONS # marks the end of turn
end

#next_turn!Object

Increment turn counter



42
43
44
# File 'lib/lib/user_interface/infopane.rb', line 42

def next_turn!
  @turn += 1
end

#turnscoreObject



29
30
31
32
33
# File 'lib/lib/user_interface/infopane.rb', line 29

def turnscore
  "Turn: #{@turn}, " \
  "Faction: FAC#{@faction}, " \
  "Score: #{@score[0]} - #{@score[1]}"
end

#updateObject



15
16
# File 'lib/lib/user_interface/infopane.rb', line 15

def update
end