Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
159 changed files
with
1,603 additions
and
1,730 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,29 @@ | ||
require 'dominion/engine' | ||
require 'dominion/card' | ||
require 'dominion/action' | ||
require 'dominion/deck' | ||
require 'dominion/game' | ||
require 'dominion/match' | ||
require 'dominion/pile' | ||
require 'dominion/scoreboard' | ||
require 'dominion/score' | ||
require 'dominion/turn' | ||
require 'dominion/victory' | ||
require 'dominion/wheel' | ||
|
||
require 'dominion/player/player' | ||
require 'dominion/player/human' | ||
require 'dominion/player/big_money' | ||
require 'dominion/player/highlander' | ||
|
||
require 'dominion/server' | ||
|
||
module Dominion | ||
include Dominion::Engine | ||
|
||
class GameFull < Exception | ||
end | ||
|
||
def self.available_sets | ||
[ Base, Seaside ] | ||
end | ||
|
||
end | ||
|
||
include Dominion # is this right? | ||
include Dominion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module Dominion | ||
class Action < Card | ||
def <=>(other) | ||
if other.is_a? Action | ||
to_s <=> other.to_s | ||
else | ||
-1 | ||
end | ||
end | ||
end | ||
end | ||
|
||
require 'dominion/action/base' | ||
require 'dominion/action/seaside' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
require 'dominion/action/base/adventurer' | ||
require 'dominion/action/base/bureaucrat' | ||
require 'dominion/action/base/cellar' | ||
require 'dominion/action/base/chancellor' | ||
require 'dominion/action/base/chapel' | ||
require 'dominion/action/base/council_room' | ||
require 'dominion/action/base/feast' | ||
require 'dominion/action/base/festival' | ||
require 'dominion/action/base/laboratory' | ||
require 'dominion/action/base/library' | ||
require 'dominion/action/base/market' | ||
require 'dominion/action/base/militia' | ||
require 'dominion/action/base/mine' | ||
require 'dominion/action/base/moat' | ||
require 'dominion/action/base/moneylender' | ||
require 'dominion/action/base/remodel' | ||
require 'dominion/action/base/smithy' | ||
require 'dominion/action/base/spy' | ||
require 'dominion/action/base/thief' | ||
require 'dominion/action/base/throne_room' | ||
require 'dominion/action/base/village' | ||
require 'dominion/action/base/witch' | ||
require 'dominion/action/base/woodcutter' | ||
require 'dominion/action/base/workshop' | ||
|
||
module Dominion | ||
module Base | ||
|
||
######################################################################### | ||
# K I N G D O M S # | ||
######################################################################### | ||
def self.available_kingdoms | ||
[ Adventurer, Bureaucrat, Cellar, Chancellor, Chapel, CouncilRoom, | ||
Feast, Festival, Gardens, Laboratory, Library, Market, Militia, Mine, | ||
Moat, Moneylender, Remodel, Smithy, Spy, Thief, ThroneRoom, Village, | ||
Witch, Woodcutter, Workshop ] | ||
end | ||
|
||
######################################################################### | ||
# B U R E A U C R A T # | ||
######################################################################### | ||
def bureaucrat_selection | ||
hand.victories.first | ||
end | ||
|
||
module Human | ||
def bureaucrat_selection | ||
return nil if hand.victories.empty? | ||
select_card hand.victories, :message=>'Select a card to put on top of your deck', | ||
:force=>true | ||
end | ||
end | ||
|
||
######################################################################### | ||
# C H A N C E L L O R # | ||
######################################################################### | ||
def use_chancellor?(turn) | ||
true | ||
end | ||
|
||
module Human | ||
def use_chancellor?(turn) | ||
get_boolean 'Would you like discard your deck?' | ||
end | ||
end | ||
|
||
######################################################################### | ||
# M O A T # | ||
######################################################################### | ||
# Return true to halt attack | ||
# Return false to continue | ||
def moat? | ||
!hand.moats.empty? | ||
end | ||
|
||
module Human | ||
def moat? | ||
return false if hand.moats.empty? | ||
get_boolean "Would you like to reveal a Moat?" | ||
end | ||
end | ||
|
||
######################################################################### | ||
# M I L I T I A # | ||
######################################################################### | ||
# Return discard list on successful attack | ||
# Return false on unsuccessful (Moat) | ||
def militia_discard | ||
return false if moat? | ||
hand[3..-1] | ||
end | ||
|
||
module Human | ||
def militia_discard | ||
return false if moat? | ||
discards = [] | ||
while hand.size > 3 | ||
discards << select_card(player.hand, :message=>"Choose a card to discard (from #{turn.player}'s Militia)", :force=>true) | ||
end | ||
return discards | ||
end | ||
end | ||
|
||
######################################################################### | ||
# S P Y # | ||
######################################################################### | ||
# Return false to halt attack | ||
# Else return spied card | ||
def spy_on(player) | ||
return false if moat? | ||
player.reveal.first | ||
end | ||
|
||
# True to discard | ||
# False to put it back on top of deck | ||
def discard_from_spy?(card, player) | ||
!(card.is_a?(Victory) || card.is_a?(Curse)) | ||
end | ||
|
||
module Human | ||
def discard_from_spy?(card, player) | ||
!get_boolean("Would you like to make #{player} discard #{card}? (Otherwise it goes back on top of their deck)") | ||
end | ||
end | ||
|
||
######################################################################### | ||
# T H I E F # | ||
######################################################################### | ||
# Return false to halt attack | ||
def thief(player) | ||
return false if moat? | ||
revealed = player.reveal 2 | ||
broadcast "#{player} revealed #{revealed.join ', '}" | ||
unless revealed.treasures.empty? | ||
card = revealed.treasures.first | ||
if card | ||
discard.unshift card | ||
broadcast "#{name} stole #{player}'s #{card}" | ||
revealed.delete card | ||
end | ||
end | ||
revealed.each{|c| player.discard.unshift c} | ||
end | ||
|
||
module Human | ||
def thief(player) | ||
return false if moat? | ||
revealed = player.reveal 2 | ||
broadcast "#{player} revealed #{revealed.join ', '}" | ||
unless revealed.treasures.empty? | ||
card = select_card revealed.treasures, :message=>"Choose a treasure to trash" | ||
if card | ||
if get_boolean("Would you like to steal #{card}?") | ||
discard.unshift card | ||
broadcast "#{name} stole #{player}'s #{card}" | ||
else | ||
game.trash.unshift card | ||
broadcast "#{name} trashed #{player}'s #{card}" | ||
end | ||
revealed.delete card | ||
end | ||
end | ||
revealed.each{|c| player.discard.unshift c} | ||
end | ||
end | ||
|
||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Dominion | ||
class Adventurer < Action | ||
|
||
def cost() 6 end | ||
def to_s() 'Adventurer' end | ||
|
||
def play(turn) | ||
treasure = [] | ||
player = turn.player | ||
while player.can_draw? && treasure.size < 2 | ||
draw = player.draw.first | ||
player.say "Drew a #{draw}" | ||
if draw.is_a?(Treasure) | ||
treasure << draw | ||
else | ||
player.discard_card draw | ||
end | ||
end | ||
treasure | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module Dominion | ||
class Bureaucrat < Action | ||
|
||
def cost() 4 end | ||
def to_s() 'Bureaucrat' end | ||
|
||
def play(turn) | ||
silver = turn.game.silvers.first | ||
if silver | ||
turn.player.deck.unshift silver | ||
turn.game.remove silver | ||
end | ||
|
||
turn.other_players.each do |player| | ||
if player.moat? | ||
turn.broadcast "#{player} revealed a Moat" | ||
else | ||
victory = player.bureaucrat_selection | ||
if victory | ||
player.hand.delete victory | ||
player.deck.unshift victory | ||
turn.broadcast "#{player} revealed a #{victory} and put it on top of their deck" | ||
else | ||
turn.broadcast "#{player} reveals #{player.hand.join ', '}" | ||
end | ||
end | ||
|
||
end | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Dominion | ||
class Cellar < Action | ||
|
||
def cost() 2 end | ||
def to_s() 'Cellar' end | ||
|
||
def play(turn) | ||
player = turn.player | ||
draws = 0 | ||
while !player.hand.empty? | ||
player.say_card_list player.hand | ||
choice = player.get_integer 'Choose card to discard', 0, player.hand.size | ||
break if choice == 0 | ||
card = player.hand[choice - 1] | ||
player.discard_card card | ||
turn.broadcast "Discarded #{card}" | ||
draws = draws + 1 | ||
end | ||
turn.draw draws | ||
turn.add_action | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module Dominion | ||
class Chancellor < Action | ||
|
||
def cost() 3 end | ||
def to_s() 'Chancellor' end | ||
|
||
def play(turn) | ||
turn.add_treasure 2 | ||
turn.player.discard_deck if turn.player.use_chancellor?(self) | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module Dominion | ||
class Chapel < Action | ||
|
||
def cost() 2 end | ||
def to_s() 'Chapel' end | ||
|
||
def play(turn) | ||
1.upto(4) do | ||
turn.player.say_card_list turn.player.hand | ||
choice = turn.player.get_integer 'Choose card to trash', 0, turn.player.hand.size | ||
return if choice == 0 | ||
card = turn.player.hand[choice - 1] | ||
turn.trash card | ||
turn.broadcast "Trashed #{card}" | ||
end | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Dominion | ||
class CouncilRoom < Action | ||
|
||
def cost() 5 end | ||
def to_s() 'Council Room' end | ||
|
||
def play(turn) | ||
turn.draw 4 | ||
turn.add_buy | ||
turn.other_players.each do |player| | ||
player.draw | ||
turn.broadcast "#{player} drew a card" | ||
end | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module Dominion | ||
class Feast < Action | ||
|
||
def cost() 4 end | ||
def to_s() 'Feast' end | ||
|
||
def play(turn) | ||
card = turn.select_card turn.game.buyable(5) | ||
turn.gain(card) if card | ||
turn.trash self | ||
end | ||
|
||
end | ||
end |
Oops, something went wrong.