medeamelana / magic Goto Github PK
View Code? Open in Web Editor NEWHaskell implementation of Magic: The Gathering
Haskell implementation of Magic: The Gathering
Right now move events don't have the last known information of an object associated with them so you can't see, for example, if an object was a creature when it was on the battlefield. Some triggers, such as that of Blood Artist, need to see this in order to know whether to trigger.
Cards like Oblivion Ring and Stuffy doll ask the player to choose another object or player and remember that choice for later. Maybe objects need to keep track of one or more mutable variables to facilitate this.
Certain cards say that a creature must attack, must block, or must be blocked (Courtly Provocateur, Reckless Brute, Predatory Rampage). Furthermore, if combat requirements would conflict with combat restrictions (things that say "can't"), all restrictions must be obeyed, and as many requirements must be obeyed as possible.
At the moment I don't know how to implement this efficiently, i.e. faster than 2^n, where n is the number of creatures involved.
Certain cards allow you to search libraries for certain cards: Evolving Wilds, Farseek, Gem of Becoming, Mwonvuli Beast Tracker, Liliana of the Dark Realms, Liliana's Shade, Ranger's Path, Shimian Specter, Diabolic Revelation, Boundless Realms.
Sometimes cards in hidden zones are revealed. There needs to be an event for this.
Replacement effects modify OneShotEffect
s before they are executed. There is currently some early, commented-out code in module Magic.Engine.Events
that deals with replacement effects but it hasn't been adapted yet to changes in the API.
Furthermore, the type of a replacement effect should be changed to [OneShotEffect] -> Contextual (Maybe (Magic [OneShotEffect]))
because some effects are interested in an entire event rather than just the individual parts. It is however much more common for cards to be interested in individual events; for these cases a helper function can be created that converts a OneShotEffect ->
version to a [OneShotEffect] ->
version.
Replacement effects are needed for cards that modify how a card enters the battlefield (e.g. the rare lands) and for planeswalkers that enter the battlefield with counters on them.
Some cards require players to make choices. Examples:
To facilitate these cards, datatype Question
needs to be expanded with a question that asks the player to choose between values.
Certains cards become copies of other objects on the battlefield (e.g. Clone). To facilitate this, a new constructor needs to be added to ModifyObject
that acts in Layer1
.
Certain cards allow you to look at parts of your library and move cards around (Augur of Bolas, Index).
One card, Odric, Master Tactician, allows the active player to choose how the defending player blocks. More generally, some cards allow a player to completely take over someone else's turn.
Some cards ask players to separate a set of objects in piles (Sphinx of Uthuun). A special kind of Question
needs to be created for this.
Certain cards allow other cards to be cast without paying their mana costs (Mindclaw Shaman, Spelltwince, Omniscience). Paying mana costs for casting spells should therefore probably be done by the engine rather than actively by the cards themselves so that sometimes the engine can decide not to ask the player to actually pay these mana costs. Additional costs still need to be paid, however, including additional mana costs.
Furthermore, certain cards increase or decrease the total cost of a spell (its mana cost + additional costs).
In the DeclareBlockersStep
, the game should ask players that are being attacked by creatures how they want to block. The game should then verify that the set of blocks is legal according to _allowBlocks
in each object in the game.
Some non-permanent objects (instants, sorceries, triggered abilities, activated abilities) create replacement effects that are not tied to a specific object and can therefore not be stored in a single object, but rather need to be stored somewhere in the world. In M13 these are:
Some effects create delayed triggered abilities. For example, Chandra, the Firebrand says in part: "-When you cast your next instant or sorcery spell this turn, copy that spell".
This effect stays applicable even if Chandra were to die before the end of the turn. Therefore such effects need to be stored somewhere globally rather than in a specific object.
Some cards allow you to choose new targets for a spell or ability on the stack (Reverberate, Redirect).
Some cards trigger not on events but when a certain state is reached in the game (Phylactery Lich). To fully implement the rules for state-based triggers like this one, they need to have IDs so we can make sure they don't trigger more ofen than necessary.
Certain cards increase or decrease a player's hand size, or remove a player's maximum hand size completely (Reliquary Tower).
When some but not all targets of a spell or ability become invalid, as many effects as possible are applied. Currently what actually happens is unspecified; this needs to be fixed.
During a test run, I destroyed an enchantment and Blood Artist's trigger ability was triggered, even though it should only be triggered when creatures die.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.