-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #85
- Loading branch information
Showing
28 changed files
with
256 additions
and
79 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module Magic | ||
class Ability | ||
attr_reader :source | ||
|
||
def initialize(source:) | ||
@source = source | ||
end | ||
|
||
def game | ||
source.game | ||
end | ||
|
||
def battlefield | ||
game.battlefield | ||
end | ||
|
||
def controller | ||
source.controller | ||
end | ||
|
||
def trigger_effect(effect, **args) | ||
source.trigger_effect(effect, source: self, **args) | ||
end | ||
|
||
def add_choice(choice, **args) | ||
source.add_choice(choice, **args) | ||
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
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,37 +1,11 @@ | ||
module Magic | ||
class ActivatedAbility | ||
attr_reader :source | ||
|
||
def initialize(source:) | ||
@source = source | ||
end | ||
|
||
class ActivatedAbility < Ability | ||
def valid_targets?(*targets) | ||
targets.all? { target_choices.include?(_1) } | ||
end | ||
|
||
def costs | ||
@costs || self.class::COSTS.dup | ||
end | ||
|
||
def game | ||
source.game | ||
end | ||
|
||
def battlefield | ||
game.battlefield | ||
end | ||
|
||
def controller | ||
source.controller | ||
end | ||
|
||
def trigger_effect(effect, **args) | ||
source.trigger_effect(effect, source: self, **args) | ||
end | ||
|
||
def add_choice(choice, **args) | ||
source.add_choice(choice, **args) | ||
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
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
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
module Magic | ||
module Cards | ||
class TeferiMasterOfTime < Planeswalker | ||
NAME = "Teferi, Master of Time" | ||
TYPE_LINE = "Legendary Planeswalker -- Teferi" | ||
cost generic: 2, blue: 2 | ||
loyalty 3 | ||
|
||
class LoyaltyAbility1 < LoyaltyAbility | ||
def loyalty_change | ||
1 | ||
end | ||
|
||
def resolve! | ||
trigger_effect(:draw_cards) | ||
add_choice(:discard) | ||
end | ||
end | ||
|
||
class LoyaltyAbility2 < LoyaltyAbility | ||
def loyalty_change | ||
-3 | ||
end | ||
|
||
def target_choices | ||
battlefield.creatures.not_controlled_by(controller) | ||
end | ||
|
||
def resolve!(target:) | ||
trigger_effect(:phase_out, target: target) | ||
end | ||
end | ||
|
||
class LoyaltyAbility3 < LoyaltyAbility | ||
def loyalty_change | ||
-10 | ||
end | ||
|
||
def resolve! | ||
2.times { game.take_additional_turn } | ||
end | ||
end | ||
|
||
def loyalty_abilities = [LoyaltyAbility1, LoyaltyAbility2, LoyaltyAbility3] | ||
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
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module Magic | ||
module Effects | ||
class PhaseOut < TargetedEffect | ||
|
||
def resolve! | ||
target.phase_out! | ||
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
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,10 +1,4 @@ | ||
module Magic | ||
class LoyaltyAbility | ||
attr_reader :planeswalker, :game | ||
|
||
def initialize(planeswalker:) | ||
@planeswalker = planeswalker | ||
@game = planeswalker.game | ||
end | ||
class LoyaltyAbility < Ability | ||
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
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
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
Oops, something went wrong.