Coder Social home page Coder Social logo

weasel's Introduction

Weasel Turn Battle System

Build Status Code Coverage crates.io Released API docs License: MIT

weasel is a customizable battle system for turn-based games.

  • Simple way to define the combat's rules, taking advantage of Rust's strong type system.
  • Battle events are collected into a timeline to support save and restore, replays, and more.
  • Client/server architecture; all battle events are verified by the server.
  • Minimal performance overhead.

Examples

use weasel::{
    battle_rules, rules::empty::*, Battle, BattleController,
    BattleRules, CreateTeam, EventTrigger, Server,
};

battle_rules! {}

let battle = Battle::builder(CustomRules::new()).build();
let mut server = Server::builder(battle).build();

CreateTeam::trigger(&mut server, 1).fire().unwrap();
assert_eq!(server.battle().entities().teams().count(), 1);

You can find real examples of battle systems made with weasel in examples.

How does it work?

To use this library, you would create instances of its main objects: server and client. You will notice that both of them are parameterized with a BattleRules generic type.
A server is mandatory to manage a game. A server can be also a client. For example, a typical single player game needs only one server.
A client is a participant to a game. It sends commands to a server on behalf of a player. A multiplayer game would have one server and multiple clients.

Once you have instantiated a server and possibly one or more clients, you are ready to begin a new game.
Games are carried forward by creating events. There are many kind of events, see the documentation to know more.

Through a server or a client you'll be able to access the full state of the battle, including the entire timeline of events.

Features

weasel provides many functionalities to ease the development of a turn based game:

  • Creatures and inanimate objects.
  • Statistics and abilities for characters.
  • Long lasting status effects.
  • Player managed teams.
  • Team objectives and diplomacy.
  • Division of the battle into turns and rounds.
  • Rules to govern the game subdivided into orthogonal traits.
  • Fully serializable battle history.
  • Cause-effect relationship between events.
  • Server side verification of clients' events.
  • Player permissions and authorization.
  • Versioning for battle rules.
  • User defined events.
  • System and user defined metrics.
  • Sinks to forward events to an arbitrary destination.
  • Small collection of predefined rules.

Contributing

Thanks for your interest in contributing! There are many ways to contribute to this project. See CONTRIBUTING.md.

License

weasel is provided under the MIT license. See LICENSE.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.