diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2023-09-11 15:15:00 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2023-09-11 15:15:00 +0200 |
commit | fae7026727c4deaaf95fdf9f329e589c98f19124 (patch) | |
tree | bd11ffc681a98510fffe1e449c5d4f5c72bae793 /lib/colonial_twilight/cards.rb | |
parent | 50686dd6037e7487479599c80890a683800f6a19 (diff) | |
download | colonial-twilight-fae7026727c4deaaf95fdf9f329e589c98f19124.zip colonial-twilight-fae7026727c4deaaf95fdf9f329e589c98f19124.tar.gz |
Cards : clean up
Diffstat (limited to 'lib/colonial_twilight/cards.rb')
-rw-r--r-- | lib/colonial_twilight/cards.rb | 76 |
1 files changed, 51 insertions, 25 deletions
diff --git a/lib/colonial_twilight/cards.rb b/lib/colonial_twilight/cards.rb index 4ffcff5..de962c0 100644 --- a/lib/colonial_twilight/cards.rb +++ b/lib/colonial_twilight/cards.rb @@ -1,34 +1,59 @@ #! /usr/bin/env ruby -# -*- coding: UTF-8 -*- +# frozen_string_literal: true -module ColonialTwilight +# rubocop:disable Style/Documentation - CARD_SINGLE=1 - CARD_FLN_MARKED=2 - CARD_ALWAYS_PLAY=4 +module ColonialTwilight + CARD_SINGLE = 1 + CARD_FLN_MARKED = 2 + CARD_ALWAYS_PLAY = 4 class Card attr_reader :num, :title - def initialize n, t, attr, a0=nil, a1=nil - @num = n - @title = t + + def initialize(num, title, attr, act0 = nil, act1 = nil) + @num = num + @title = title @attributes = attr - @a0 = a0 - @a1 = a1 + @act0 = act0 + @act1 = act1 + end + + def dual? + @attributes & CARD_SINGLE.zero? + end + + def single? + @attributes & CARD_SINGLE == CARD_SINGLE end - def dual?; @attributes & CARD_SINGLE == 0 end - def single?; @attributes & CARD_SINGLE == CARD_SINGLE end - def fln_marked?; @attributes & CARD_FLN_MARKED == CARD_FLN_MARKED end - def always_play?; @attributes & CARD_ALWAYS_PLAY == CARD_ALWAYS_PLAY end - def capability?; false end - def fln_effective?; false end - def fln_effectiveness; 0 end + + def fln_marked? + @attributes & CARD_FLN_MARKED == CARD_FLN_MARKED + end + + def always_play? + @attributes & CARD_ALWAYS_PLAY == CARD_ALWAYS_PLAY + end + + def capability? + false + end + + def fln_effective? + false + end + + def fln_effectiveness + 0 + end + def fln_playable? # reduce GOV support or resources or commitment # shift France Track toward F # place FLN base or increase FLN resources false end + def check # @attributes.each do |attr| raise "unknown attribute : #{attr}" if attr not in ATTRS end # puts single? @@ -39,31 +64,32 @@ module ColonialTwilight end class CardAction - def initialize t, c - @txt = t - @condition=c + def initialize(txt, cond) + @txt = txt + @condition = cond end end class Deck attr_reader :cards + def initialize @cards = {} add_card 0, 'None', nil, nil - add_card 1, 'Quadrillage', 0, CardAction.new('Place up to all French Police in Available in up to 3 spaces', {:what=>:french_police,:from=>:available}) + add_card 1, 'Quadrillage', 0, CardAction.new('Place up to all French Police in Available in up to 3 spaces', { what: :french_police, from: :available }) end - def pull n; @cards[n > 0 ? 1 : 0] end # FIXME + def pull(num) + @cards[num.positive? ? 1 : 0] # FIXME + end private - def add_card num, title, attrs, action + def add_card(num, title, attrs, _action) @cards[num] = Card.new num, title, attrs @cards[num].check end - end - end # 'Balky Conscripts' |