Skip to content

lerrua/merlin-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Merlin Engine

merlin

Merlin is a micro-engine written in Python for build RPG Games.

It's for fun, made to learn, search and improve my knowledge about create my own RPG engine, hope you like and help me improve it. The goal is keep using pure Python for be used everywhere, any lib, desktop or web application.

installation:

$ git clone git@github.com:lerrua/merlin-engine.git
$ cd merlin-engine
$ python setup.py install

usage example:

Prepare opponents for the battle, basically are two dicts with attributes 'base_attack' and 'base_hp'.

>>> from merlin.engine.battle import Prepare

# using sample heroes and monsters lists
>>> from merlin.boot import heroes, monsters
>>> aragorn = heroes[0]
>>> orc = monsters[0]

>>> hero = Prepare(aragorn)
>>> foe = Prepare(orc)

>>> foe.status
{'base_hp': 90, 'name': 'Orc', 'base_attack': 20, is_dead: False}

>>> hero.status
{'base_hp': 170, 'name': 'Aragorn', 'base_attack': 50, is_dead: False}

Here's a sample battle:

>>> hero.attack(foe)
40
>>> foe.status
{'base_hp': 40, 'name': 'Orc', 'base_attack': 20, is_dead: False}

>>> hero.attack(foe)
foe is dead.
-10
>>> foe.status
{'base_hp': -10, 'name': 'Orc', 'base_attack': 20, is_dead: True}

We have some available actions after battle.

>>> hero.attack(foe)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "merlin/engine/battle.py", line 22, in attack
    raise DeadException('foe is already dead! Stop hit him!')
DeadException: foe is already dead! Stop hit him!

# don't hit the dead body, collect the droppable items
>>> hero.collect(foe)

About

A micro-engine written in Python for build RPG Games

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages