Class: Condition

Inherits:
Object
  • Object
show all
Defined in:
lib/software_challenge_client/condition.rb

Overview

Das Ergebnis eines Spieles. Ist im ‘GameState#condition` zu finden, wenn das Spiel beendet wurde.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(winner, reason) ⇒ Condition

Initializes the winning Condition with a player

Parameters:

  • winner (Player)

    winning player

  • reason (String)

    why the player has won



18
19
20
21
# File 'lib/software_challenge_client/condition.rb', line 18

def initialize(winner, reason)
  @winner = winner
  @reason = reason
end

Instance Attribute Details

#reasonString (readonly)

Returns Grund fuer Spielende.

Returns:

  • (String)

    Grund fuer Spielende



13
14
15
# File 'lib/software_challenge_client/condition.rb', line 13

def reason
  @reason
end

#winnerPlayer (readonly)

Returns Spieler, der das Spiel gewonnen hat.

Returns:

  • (Player)

    Spieler, der das Spiel gewonnen hat.



9
10
11
# File 'lib/software_challenge_client/condition.rb', line 9

def winner
  @winner
end

Instance Method Details

#draw?Boolean

Überprüfe ob es ein Unentschieden gab

Returns:

  • (Boolean)


24
25
26
# File 'lib/software_challenge_client/condition.rb', line 24

def draw?
  @winner.nil?
end