-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.rb
76 lines (59 loc) · 1.63 KB
/
player.rb
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
class Player < ActiveRecord::Base
include Blocking
include Actions
include MetaExtensions
include Board
belongs_to :team
has_one :status
serialize :skills
attr_accessor :unused_skills
def initialize(*args)
super(*args)
self.skills.map{|s| s.titlecase.gsub(" ", "")}.each do |skill|
self.class_eval "include #{skill}"
end
self.unused_skills = self.skills.map(&:to_sym)
end
def start_action
end
def end_action
end
def game
self.team.game
end
def use_skill(skill)
self.unused_skills.delete(skill)
end
def gives_assists(target)
return false unless self.adjacent?(target)
return adjacent_players.select{|p| p.team != self.team} == [target]
end
def use_reroll(action, *args)
game.use_reroll(self.team)
self.send(action, *args)
end
def resolve_pass_action(target_square)
end
def resolve_move_action
end
def resolve_block_action(target)
positive_assists = self.team.players.select{|p| p.gives_assists(target)}.size
negative_assists = game.opposing_team(self).players.select{|p| p.gives_assists(self)}.size
mod_str = self.st + positive_assists - negative_assists
if mod_str < target.str.to_f/2
return game.roll(:third_dice_block)
elsif mod_str < target.str
return game.roll(:half_dice_block)
elsif mod_str == target.str
return game.roll(:one_dice_block)
elsif mod_str > target.str*2
return game.roll(:two_dice_block)
else mod_str > target.str
return game.roll(:three_dice_block)
end
end
def resolve_intercept_action
end
def get_hit
end
end