SFRPG
http://sfrpg-discussion.net/

Teaching myself Python 3 through Traveller
http://sfrpg-discussion.net/viewtopic.php?f=45&t=3205
Page 1 of 1

Author:  Golan2072 [ Wed May 31, 2017 1:49 pm ]
Post subject:  Teaching myself Python 3 through Traveller

As you may have seen from my previous threads, I am slowly teaching myself Python 3 by writing various RPG-related scripts, primarily for Traveller (or the Cepheus Engine).

I am intermittently working on my sector generator, but now am trying my hand at a character generator. This is a very useful project, as it allows me to experiment with Object-Oriented Programming. This is my FIRST EVER EXPERIENCE with OOP, and so far is going very well; I have already learned about Inheritance.

I also learned quite a lot about Dictionaries from dealing with the skill list.

The main concept is this is a super-class called Career which has all the chargen methods, then a specific career class which inherits from it and sets the career values (enlistment, survival, skill lists, etc), then the character himself who is also a class and inherits from the specific career class.

All classes except for the character itself will be in a "library" py file, with the program's "mechanics" (the generation process itself, saving to file, etc) being in the "main" py file.

Very enjoyable and educative so far!

Author:  Matt Wilson [ Wed May 31, 2017 4:17 pm ]
Post subject:  Re: Teaching myself Python 3 through Traveller

I'm about to head to the library to pick up a copy of Learn Python the Hard Way that I placed on hold! Hopefully I can find some RPG-related opportunities to practice what I learn.

Author:  EDG [ Wed May 31, 2017 7:02 pm ]
Post subject:  Re: Teaching myself Python 3 through Traveller

that's pretty much how I learned what I know of Python too :). Though I'm not quite so advanced as to know how Lists and Dictionaries work.

Author:  Golan2072 [ Wed May 31, 2017 8:19 pm ]
Post subject:  Re: Teaching myself Python 3 through Traveller

Lists and Dictionaries become two of your most powerful programming tools once you learn how to use them properly. They save you SO MUCH work and excess code.

Author:  Golan2072 [ Wed Feb 07, 2018 5:26 pm ]
Post subject:  Re: Teaching myself Python 3 through Traveller

My current idea is to use nested dictionaries to create the career tables in the (still hypothetical) CT/CE character generator.

The levels of this data structure would be:
1) A dictionary of careers, with the career name being the key.
2) In each career, a dictionary of tables (skills and mustering out), with the table type being the key.
3) Each table would be a list. I already have a simple function (called random_choice) ready to randomly pick an item from a list.

So, for example:

services={}
services[marines][muster]=["Low Passage", "+1 EDU", "Weapon", "Mid Passage", "+1 SOC", "High Passage", "Explorer's Society"]

And then, if I recall the syntax correctly, to choose from it:

benefit=random_choice(services[marines[muster]])

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/