software_challenge_client 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f6e73a26e7e73031e6e8753b4530a3a97d7c6d4
4
- data.tar.gz: 94b865f5a9919c92fdd383c7ee130b5a8444cc2a
3
+ metadata.gz: c4074b13fd465d18b7149f6900ebc838c8339c1a
4
+ data.tar.gz: b906a5f6a650d5a166552973622da994b9939ffc
5
5
  SHA512:
6
- metadata.gz: 2af181e53250e162c328d70512f12e98c01535f5cea29570dd787c34a2627575d73bd8ee832e4b72ffd33e390d15b064014b0f6d6019269cccd73c4d21d50a9a
7
- data.tar.gz: 57434f1b54bd0723e8d1af763780cc3ad25cb79ec0476eeb924d1b812d4862e05451a1b88baf98a9816860e0c4b8c9d18c0b7ffb348e129a93f917aac8d32922
6
+ metadata.gz: 6f99030db786cba8ef7689faacae933e9b12d9f913548290a7c10f9605017eff041621773b94dbf4116a9512cc1169539c127cdafa36a6dd8f18287f34643a33
7
+ data.tar.gz: 66c02fbccbb2f00b699b83b3e8f61a3aec7a6c8cb3fd3c51048182f3d4a3b1e2c8e621243bc7615473c4e2613ee19fa673afd84ae5b85791d3e40754c2112af7
data/RELEASES.md CHANGED
@@ -1,3 +1,9 @@
1
+ = 0.3.0
2
+
3
+ - Fixed bug where wrong (old) method getMove was called, the new name is
4
+ move_requested
5
+ - Improved end game handling
6
+
1
7
  = 0.2.0
2
8
 
3
9
  - First working version for Mississippi Queen
@@ -82,7 +82,7 @@ class Network
82
82
 
83
83
  line =''
84
84
  char = ''
85
- while line != "</room>" && !(char = @socket.getc).nil?
85
+ while (line != "</room>" && line != "</protocol>") && !(char = @socket.getc).nil?
86
86
  line+=char
87
87
  if char=='\n' || char==' '
88
88
 
@@ -97,11 +97,12 @@ class Network
97
97
 
98
98
  # Remove <protocol> tag
99
99
  @receiveBuffer = @receiveBuffer.gsub('<protocol>', '')
100
+ @receiveBuffer = @receiveBuffer.gsub('</protocol>', '')
100
101
 
101
102
  logger.debug "Received XML from server: #{@receiveBuffer}"
102
103
 
103
104
  # Process text
104
- @protocol.process_string("<msg>#{@receiveBuffer}</msg>");
105
+ @protocol.process_string(@receiveBuffer);
105
106
  self.emptyReceiveBuffer
106
107
  end
107
108
  return true
@@ -50,9 +50,11 @@ class Protocol
50
50
  case name
51
51
  when 'board'
52
52
  logger.debug @gamestate.board.to_s
53
- when 'condition'
54
- logger.info 'Game ended'
55
- @network.disconnect
53
+ when 'data'
54
+ if @context[:data_class] == 'result'
55
+ logger.info 'Got game result'
56
+ @network.disconnect
57
+ end
56
58
  end
57
59
  end
58
60
 
@@ -69,9 +71,10 @@ class Protocol
69
71
  logger.info 'roomId : ' + @roomId
70
72
  when 'data'
71
73
  logger.debug "data(class) : #{attrs['class']}"
74
+ @context[:data_class] = attrs['class']
72
75
  if attrs['class'] == 'sc.framework.plugins.protocol.MoveRequest'
73
76
  @client.gamestate = gamestate
74
- move = @client.getMove
77
+ move = @client.move_requested
75
78
  sendString(move_to_xml(move))
76
79
  end
77
80
  if attrs['class'] == 'error'
@@ -122,6 +125,9 @@ class Protocol
122
125
  @gamestate.lastMove.add_action_with_order(Push.new(Direction.find_by_key(attrs['direction'].to_sym)), attrs['order'].to_i)
123
126
  when 'condition'
124
127
  @gamestate.condition = Condition.new(attrs['winner'], attrs['reason'])
128
+ when 'left'
129
+ logger.debug 'got left event, terminating'
130
+ @network.disconnect
125
131
  end
126
132
  end
127
133
 
@@ -1,4 +1,4 @@
1
1
  # encoding: UTF-8
2
2
  module SoftwareChallengeClient
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: software_challenge_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - 'kwollw '
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2016-10-07 00:00:00.000000000 Z
13
+ date: 2016-10-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: typesafe_enum
@@ -275,7 +275,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
275
275
  version: '0'
276
276
  requirements: []
277
277
  rubyforge_project:
278
- rubygems_version: 2.5.1
278
+ rubygems_version: 2.6.6
279
279
  signing_key:
280
280
  specification_version: 4
281
281
  summary: This gem provides functions to build a client for the coding competition