summaryrefslogtreecommitdiffstats
path: root/lib/colonial_twilight/fln_bot.rb
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2020-09-02 16:17:56 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2020-09-02 16:17:56 +0200
commit314b20c23a1362eef24efc6f80c7005ec24e878d (patch)
tree7ac4ffcc70b30fcadf0f2378f2f4abc1d316ce22 /lib/colonial_twilight/fln_bot.rb
parentf5b0433c59d772ba8cf6470a38c60279491e53c0 (diff)
downloadcolonial-twilight-314b20c23a1362eef24efc6f80c7005ec24e878d.zip
colonial-twilight-314b20c23a1362eef24efc6f80c7005ec24e878d.tar.gz
get ready for GOVPlayer
Diffstat (limited to 'lib/colonial_twilight/fln_bot.rb')
-rw-r--r--lib/colonial_twilight/fln_bot.rb91
1 files changed, 2 insertions, 89 deletions
diff --git a/lib/colonial_twilight/fln_bot.rb b/lib/colonial_twilight/fln_bot.rb
index 42d3883..ae4536b 100644
--- a/lib/colonial_twilight/fln_bot.rb
+++ b/lib/colonial_twilight/fln_bot.rb
@@ -3,100 +3,13 @@
module ColonialTwilight
- class Player
-
- attr_reader :faction
-
- def initialize game, faction
- @game = game
- @board = game.board
- @ui = game.ui
- @faction = faction
- @debug = game.options.debug_bot
- @possible_actions = nil
- end
-
- def conducted_action
- a = nil
- if not @card.nil?
- raise "Operation #{@operation} conducted with event" if not @operation.nil?
- raise "Special Activity #{@special_activity} conducted with event" if not @special_activity.nil?
- a = :event
- elsif not @special_activity.nil?
- a = :ope_special
- else
- if @operation_count == 0
- a = :pass
- elsif @operation_count == 1
- a = :ope_limited
- else
- a = :ope_only
- end
- end
- raise "#{a} has been conducted but is not allowed" if not @possible_actions.include? a
- puts "Conducted action is : #{a}" if @debug
- a
- end
-
- private
-
- def first_eligible?
- @game.actions.size == 0
- # @possible_actions.length == 5
- end
-
- def may_play_event?
- not @card.nil? and @possible_actions.include? :event
- end
-
- def limited_ope_only?
- (@possible_actions.size == 2 and @possible_actions.include? :ope_limited)
- end
-
- def limited_ope_done?
- limited_ope_only? and @operation_count == 1
- end
-
- def may_conduct_special_activity? sp
- r = @possible_actions.include? :ope_special
- r &= (sp == @special_activity) if not @special_activity.nil?
- r
- end
-
- def operation_done ope
- raise "try to conduct ope #{ope} over #{@operation}" if not (@operation.nil? or @operation == ope)
- raise "cannot conduct another" if @operation_count > 0 and limited_ope_only?
- @card = nil
- @operation = ope
- @operation_count += 1
- end
-
- def special_activity_done sp
- raise "try to conduct special activity #{sp} over #{@special_activity}" if not (@special_activity.nil? or @special_activity == sp)
- raise "cannot conduct a special activity" if not may_conduct_special_activity? sp
- @card = nil
- @special_activity = sp
- @special_activity_count += 1
- end
-
- end
-
# Country.independant
class FLNBot < Player
- def play card, possible_actions
- @card = card
+ def play possible_actions
@possible_actions = possible_actions
-
- @operation = nil
- @operation_count = 0
- @special_activity = nil
- @special_activity_count = 0
-
- @selected_spaces = []
- @expended_resources = 0
-
+ _init
_start
end