-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathround.rb
More file actions
53 lines (46 loc) · 1.21 KB
/
Copy pathround.rb
File metadata and controls
53 lines (46 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- coding: utf-8 -*-
require_relative 'server-settings.rb'
class Round
attr_reader :round, :opponent_moves
attr_accessor :super_region_changes
def initialize(settings)
@round = 0
@settings = settings
@opponent_moves = []
@super_region_changes = {:lost => [], :gained => []}
end
def next_round()
@round += 1
@opponent_moves = []
end
def update_map()
@super_region_changes = {:lost => [], :gained => []}
end
##
# Return the maximum number of rounds for this game
def max_rounds()
@settings[:max_rounds]
end
##
# Number of armies that can be placed this round
def armies()
@settings[:starting_armies]
end
def opponent_moves=(line)
moves = []
while not line.empty?
name = line.shift
command = line.shift
case command
when 'attack/transfer' then
from, to, number = line.shift.to_i, line.shift.to_i, line.shift.to_i
@opponent_moves << [from, to, number]
when 'place_armies' then
in_region, number = line.shift.to_i, line.shift.to_i
@opponent_moves << [in_region, number]
else
raise format('Unknown command %s, Reffer to manual on theaigames.com', command)
end
end
end
end