Weasel Turn Battle System
Powers function similar to statistics and to abilities, with the only difference that they can be activated only by teams.
New methods and associated types have been added to TeamRules
. New events (AlterPowers
, RegeneratePowers
and InvokePower``) can be fired to manipulate powers.
Improved the ergonomics of handling errors from EventProcessor
. ProcessOutput
has a new method result()
to get a WeaselResult
.
For example, the following function is now valid:
fn fire_event<R, P>(processor: &mut P) -> WeaselResult<(), R>
where
R: BattleRules + 'static,
P: EventProcessor<R>,
{
DummyEvent::trigger(processor).fire().result()?;
Ok(())
}
This change swaps around the concept of round
and turn
in weasel, making it consistent with the popular definition in turn based games.
Now every actor acts during a turn. A round can contain one or more of these turns.
RemoveEntityTrigger
.This new event trigger makes it easier to delete an entity when you have an EntityId
instead of a CreatureId
or an ObjectId
.
Re-exported the most useful names at the root of the crate.
ConcludeMissionTrigger
. It is now ConcludeObjectivesTrigger
.CharacterRules
.The new methods on_character_added
and on_character_transmuted
can be used to define specific behaviors when an entity is added or removed from the battle.
Client
and Server
are now Send
.This change should help integrate weasel into multithreaded game. Both client and server can now be sent between threads.
Notice: there are additional Send
requirements on some traits.
FlatVersionedEvent
and FlatClientEvent
now have methods to access their internal fields.
Rounds
and an EndTurn
event.Added counters for rounds and turns in Rounds
. These can be accessed with completed_rounds
and completed_turns
.
The rounds counter is automatically increased by the library. The turns counter, instead, must be manually increased by firing an event of type EndTurn
.
The metric ROUNDS_STARTED
was removed as its functionality is now covered by completed_rounds
.
The new example 'King of the hill' is a card game with multiplayer over network for three players.
BattleController
trait.This new trait allows the user to write generic code around structure that have ownership of a Battle
object.
The trait is implemented by Client
and Server
.
CREATURES_CREATED
and OBJECTS_CREATED
had the same internal id.Introduced new methods in Battle
and in some other components to let the player modify the rules and the models in the context of custom events.
A round can be started by multiple actors with the new function StartRound::trigger_with_actors
. All actors can use their abilities, in no particular order.
EndRound
automatically ends the round for everyone.
It's now possible to implement status effects with weasel. A status effect can be inflicted with the event InflictStatus
and removed with the event ClearStatus
.
You can specify your own status effects' definition with the new associated types Potency
, Status
and StatusesAlteration
.
The new methods generate_status
and alter_statuses
in CharacterRules
let you define how statuses are created and modified.
The new methods apply_status
, update_status
and delete_status
in FightRules
let you define what are the side effects of a status.
Added the event EnvironmentRound
to simulate a round for all inanimate objects, to trigger their status updates.
Renamed ActorRules
's alter
into alter_abilities
and CharacterRules
's alter
into alter_statistics
for consistency with the new alter_statuses
.
New example, status
, to demonstrate how to define and use status effects.
Event's origin is not overridden anymore by the server while processing events put into an EventQueue
.
ActorRules
.The method activable
now take BattleState
as argument. This allows to decide whether an ability is activable depending on the entire state of the battle, not only the state of the actor.
The methods on_round_start
and on_round_end
now take BattleState
as argument as well. This let the user implement passive skills such as gain x health for each adjacent enemy at the end of every round.
Some trait methods are used to verify if an operation is allowed.
allow_new_entity
, activable
, check_move
now return a WeaselResult
instead of a bool. In this way the user can specify the reason for which the operation has been rejected.
WeaselError::GenericError
.Added a new variant of WeaselError
to represent generic errors that don't have additional information.
New example, undo
, to demonstrate how to undo/redo events.
The example passive
shows instead how to define simple passive abilities.
HashMap
with IndexMap
.Rust's HashMap with default Hasher doesn't guarantee a consistent order while iterating over its elements. This can be an issue in few corner cases. For instance, iterating over entities and generating side effects might cause a desync if the server and the client iteration order are different.
IndexMap
, instead, provides a consistent iteration order across different executions.
Introduced a new struct to represent inanimate entities: Object
.
The new associated type ObjectId
in CharacterRules
let you customize the objects' id type.
Objects can be placed on the battlefield and possess statistics. However, they don't know any ability and they can't take any action.
Two new events, CreateObject
and RemoveObject
, can be used to add and remove objects from the battle.
Battle
API.Added more methods to modify the state of Battle
and of its submodules (Rounds
, Entropy
, Space
, Entities
). This's done to increase the power of user defined events.
It's now possible to manually set the origin of an event. The Originated
decorator let you do this on an EventTrigger
.
Added doc tests with a simple example for all events in weasel.