-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayer.rb
More file actions
104 lines (84 loc) · 1.34 KB
/
player.rb
File metadata and controls
104 lines (84 loc) · 1.34 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
require 'socket'
class Player
def initialize
@active = false
@flagged_cards = Array.new
@name = ''
@raw_hand = Array.new
@position = -1
@score = 0
@score_this_round = 0
end
def score_this_round
@score_this_round
end
def score_this_round=(value)
@score_this_round = value
end
def score
@score
end
def score=(value)
@score = value
end
def deal_card(i)
@raw_hand.push(i)
end
def join(s, name, position)
@socket = s
@name = name
@active = true
@position = position
end
def flag_cards(suit)
#suit = cardID/13
print @raw_hand
@raw_hand.each do |c|
s = c/13
if suit == s and @flagged_cards.include?(c) == false
@flagged_cards.push(c)
end
end
end
def flagged_cards
@flagged_cards
end
def active
@active
end
def name
@name
end
def set_name(new_name)
@name = new_name
end
def s
@socket
end
def socket
@socket
end
def position
@position
end
def hand
@raw_hand
end
def hand_msg
msg = ''
@raw_hand.each do |c|
msg << c.to_s
msg << ','
end
msg[0...msg.length-1]
end
def new_trick
@flagged_cards.clear
@hand.clear
end
def new_round
@raw_hand.clear
@flagged_cards.clear
@score_this_round = @score
end
end