It seems that you're using an outdated browser. Some things may not work as they should (or don't work at all).
We suggest you upgrade newer and better browser like: Chrome, Firefox, Internet Explorer or Opera

×
===========
Project died in 2018 due to lack of time.
===========
Post edited February 22, 2023 by DOWL
Do I get commission for each one posted? Also, you may get some copyright issues, for instance if I used < >Marine Games Workshop would take a legal dump on my head.

Always interested to see a working demo however, been dabbling since text adventures on Spectrum. Is it a bit rogue like as there is a python library already available for rogue likes which you could compare your code to:
See down the page at:
http://www.roguetemple.com/
Section: The 2015 7DRL Challenge is almost here!
For a whole load, but one is python
http://roguecentral.org/doryen/libtcod/
avatar
nightcraw1er.488: Do I get commission for each one posted? Also, you may get some copyright issues, for instance if I used < >Marine Games Workshop would take a legal dump on my head.
No commission as I have little money, so far I've spent £0 on the game. However, any suggestions will remain 'yours' as only the code structure is copyrighted - all names are public and anyone can use them. As for the other copyright issues, they are a bit of a problem, which is why I need unique or not blatantly copyrighted names for things.
avatar
nightcraw1er.488: Always interested to see a working demo however, been dabbling since text adventures on Spectrum. Is it a bit rogue like as there is a python library already available for rogue likes which you could compare your code to:
See down the page at:
http://www.roguetemple.com/
Section: The 2015 7DRL Challenge is almost here!
For a whole load, but one is python
http://roguecentral.org/doryen/libtcod/
It's not a roguelike, more of an adventure game. Death will result in a penalty - though I haven't worked out what that will be yet, but you'll keep progress and most likely items as well. Thanks for the links though, they would be a great help in the future if I make a roguelike (Which I probably will).
Post edited July 06, 2017 by T.Hodd
avatar
T.Hodd: Ideally, post in the following format so I can put it in the game more easily:
shop("a NAME","NAME", 0, 0, 0, 0, 0, 0, 0, 0000)
Eg: shop("a sword","sword", 0, 0, 0, 0, 0, 0, 0, 0000)

Any names for enemies can be post in this format:
monster("NAME", 0, 0, 0, 0, 0, 0)
Eg: monster("Dave", 0, 0, 0, 0, 0, 0)
Maybe just a technical remark. It's not very good practice to put data inside the code. You could make a json, xml, even csv file to store all your game data and then load them into your game. That way you don't need to recompile everything if you change something, it's all in one place, it's more modular, clean and robust solution.

Maybe worth a consideration.
Post edited July 06, 2017 by Nightblair
I assume you have been through the biig online databases for specific eras, e.g. medieval:
http://www.medievalwarfare.info/weapons.htm

Another thing most games use to expand the arsenal is to have various levels, sharp/blunt, serrated etc. or iron, steel, blue steel etc.
That can then be applied to all weapons/armour, serrated sword for instance.

Monsters is a bit more difficult once you have gone through the natural world.
avatar
Nightblair: Maybe just a technical remark. It's not very good practice to put data inside the code. You could make a json, xml, even csv file to store all your game data and then load them into your game. That way you don't need to recompile everything if you change something, it's all in one place, it's more modular, clean and robust solution.
Thanks for pointing this out, these are exactly the sort of things I forget about. One problem I'm having at the moment is getting it to be able to put the string from the read() into the shop class as this requires 9 arguments. This could be done by specifying which part to read for each section and then converting to shop, but this'll be tricky for unkown lengths. Already added this to the project planning page as it'll be critical for mod support.
avatar
T.Hodd: Thanks for pointing this out, these are exactly the sort of things I forget about. One problem I'm having at the moment is getting it to be able to put the string from the read() into the shop class as this requires 9 arguments. This could be done by specifying which part to read for each section and then converting to shop, but this'll be tricky for unkown lengths. Already added this to the project planning page as it'll be critical for mod support.
Yes, mods will be so much easier with this done.

In my game, I've used json and python can convert json to objects directly. Then you just need one argument to your monster or shop class and that is the json parsed object.

you can init your json with this:
def loadjson(filename):
with open(filename) as jsonfile:
jsondata = json.load(jsonfile)
return jsondata

... load the data as: self.moninfo = jsonInit.loadjson("resources/data/creatures.jsn")

... this is the constructor for the monster class:
def __init__(self, parameters):
self.parameters = dict(parameters)

... and this is creation of the monster itself:
player = Monster(self.moninfo[PLAYERCREATURE], self)
(yes, player is the monster too ;)

You also need to create few methods for checking the paramaters in the object, like getparameter which will load it from the dictionary, etc. And you need a good discipline in checking the optional parameters so your game won't crash, as python is dynamically referenced.

I'm not a good pythoner, but it worked for my game. However better to do it soon, as you won't have to refactor so much code then.
Yes, thats what Mount & Blade does, has all the data in files which are easy to edit - python lists - so modding is pretty easy.
https://forums.taleworlds.com/index.php?topic=6575.0
avatar
Nightblair: ... load the data as: self.moninfo = jsonInit.loadjson("resources/data/creatures.jsn")
I'm getting NameError: name 'jsonInit' is not defined. Any ideas?
Post edited July 06, 2017 by T.Hodd
This is relevant to my interests.
avatar
Nightblair: ... load the data as: self.moninfo = jsonInit.loadjson("resources/data/creatures.jsn")
avatar
T.Hodd: I'm getting NameError: name 'jsonInit' is not defined. Any ideas?
It's probably some custom thing. Python now has a default json module (you still have to import it, though)
import json

then you can parse a string with
your_var = json.loads(your_string)

The variable will be a dict or a list of dicts, depending on the json content.


There are probably (??) better libraries out there that handle shitty jsons better that you can look into now or swap in later when the game is nearing release and would noticeably benefit from improved handling of other people's shitty jsons. The default module works well for most purposes.
Post edited July 06, 2017 by Starmaker
avatar
Nightblair: ... load the data as: self.moninfo = jsonInit.loadjson("resources/data/creatures.jsn")
avatar
T.Hodd: I'm getting NameError: name 'jsonInit' is not defined. Any ideas?
Sorry, I've copied these snippets straight from my code with little editing. jsonInit is just name of my class, as I've kept the json loader in a separate file to keep the code tidy. You can freely remove it.
avatar
Starmaker:
avatar
Nightblair:
Yes! Thank you it works a treat. For Reference, the final code:

import json

with open("Items.json") as jsonfile:
jsondata = json.load(jsonfile)

class shop(object):
def __init__(self, parameters):
self.parameters = dict(parameters)

weapon = shop(jsondata)
print(weapon.parameters["iD"])
Post edited July 06, 2017 by T.Hodd
Regarding your battle code, everything should be generalized and encapsulated as much as possible. For example, why do you keep monsters in unique variables? Keep them in a list instead:

enemies = []
for i in range(num_enemies):
____enemies.append(my_new_monster) #____ stands for 4 spaces, because forum

If you delete dead monsters from a list, you can then check if the player won via
if not enemies:
# do things

If you don't delete dead monsters from this list, you can (for example) keep a running total of incapacitated actors for each side:
if len(enemies) == num_dead_enemies:
#win

This can be generalized even further by having a variable (structurally unlimited, but of course a game just can have content restrictions) number of factions. One of those is the player's; then actors can switch factions (suppose the pc stabs an npc and the npc goes to bat for team monster or fight independently or flee).

Attacks, of course, also need to be encapsulated. When an actor gets a turn, you update a list of available actions for the actor, and each of the actions and their consequences is described somewhere else. You have a list of actor stats (not a python list, a regular human list). From that list, you can brainstorm a list of effects. Implement those effects as functions. From that list, you can brainstorm a list of attacks. Implement those attacks as functions calling effect functions. Then, when the player acts, s/he picks an action, and when a monster acts, you call the AI. Then the action is processed normally, and after each one, you check if the battle is over. If it's not, adjust the initiative order in your Battle.py and pop the next actor.

Also, this way you can have attacks and effects out of battle. Stepped on a Lego in a CYOA sequence? Run the physical damage effect on the character instance.

Keep the game design and media content of attacks in jsons, then parse said jsons at init or perhaps on demand (it's not like text games are particularly resource-heavy, and it'll be easier for you to mod the game as it runs).
avatar
Starmaker:
Thank you for your suggestions, I've added them to the list of battle engine improvements.

Anyone know how to format .json properly? So far I've put the equipment into the new format, here's an extract:

{"o_name1": "his fists", "o_name2": "his fists", "h_effect": 0, "p_effect": 0, "req_xp": 0, "price": 0, "rarity": 1, "iD": 1000}
{"o_name1": "a rusty knife", "o_name2": "his rusty knife", "h_effect": 0, "p_effect": 0.5, "req_xp": 10, "price": 5, "rarity": 0, "iD": 1001}
{"o_name1": "a copper sword", "o_name2": "copper sword", "h_effect": 0, "p_effect": 1, "req_xp": 25, "price": 50, "rarity": 0, "iD": 1002}
{"o_name1": "an iron Sword", "o_name2": "iron sword", "h_effect": 0, "p_effect": 2, "req_xp": 50, "price": 100, "rarity": 1, "iD": 1003}
{"o_name1": "a magic sword", "o_name2": "magic sword", "h_effect": 0, "p_effect": 3, "req_xp": 200, "price": 200, "rarity": 2, "iD": 1004}
{"o_name1": "a bluesteel sword", "o_name2": "bluesteel sword", "h_effect": 0, "p_effect": 4, "req_xp": 400, "price": 400, "rarity": 2, "iD": 1005}
{"o_name1": "a flame sword", "o_name2": "flame sword", "h_effect": 0, "p_effect": 5, "req_xp": 800, "price": 1000, "rarity": 2, "iD": 1006}
{"o_name1": "Swordy Mc SwordFace", "o_name2": "Swordy Mc SwordFace", "h_effect": 0, "p_effect": 7, "req_xp": 1500, "price": 4000, "rarity": 3, "iD": 1007}
{"o_name1": "a holy sword", "o_name2": "holy sword", "h_effect": 0, "p_effect": 8, "req_xp": 3000, "price": 4500, "rarity": 4, "iD": 1008}
{"o_name1": "a heavy sword", "o_name2": "heavy sword", "h_effect": 0, "p_effect": 11, "req_xp": 5000, "price": 6500, "rarity": 4, "iD": 1009}


The problem is, I get syntax errors due to it missing punctuation to seperate each weapon. What do I use to seperate the weapons?
avatar
T.Hodd: Anyone know how to format .json properly? So far I've put the equipment into the new format, here's an extract:

The problem is, I get syntax errors due to it missing punctuation to seperate each weapon. What do I use to seperate the weapons?
You need to put comma after each {}. Not including the last one.

so for example:
{
{"o_name1": "his fists", "o_name2": "his fists", "h_effect": 0, "p_effect": 0, "req_xp": 0, "price": 0, "rarity": 1, "iD": 1000},
{"o_name1": "a rusty knife", "o_name2": "his rusty knife", "h_effect": 0, "p_effect": 0.5, "req_xp": 10, "price": 5, "rarity": 0, "iD": 1001},
{"o_name1": "a rusty knife", "o_name2": "his rusty knife", "h_effect": 0, "p_effect": 0.5, "req_xp": 10, "price": 5, "rarity": 0, "iD": 1001}
}
Post edited July 06, 2017 by Nightblair