• Welcome to the new COTI server. We've moved the Citizens to a new server. Please let us know in the COTI Website issue forum if you find any problems.
  • We, the systems administration staff, apologize for this unexpected outage of the boards. We have resolved the root cause of the problem and there should be no further disruptions.

New Ruby tools repo

Leitz

SOC-14 1K
Admin Award
Baron
I'm starting to take some of the Ruby tools I'm using and put them into a repo. Since I took a MongoDB class I'm trying to use that more. No specific performance or "best use case" reason, just to do it.

The general direction is to have a data store for the games I'm in and the fiction I write, which are based on the games I'm in. A web UI would be nice but I haven't gotten there yet. By separating data store from code others can use the data and code in their preferred language.
 
I'm not the best code monkey on CoTI but I have fun. My latest is a chapter compiler.

I use LibreOffice to write fiction and save the files as straight text. Each chapter might have 1-4 scenes in it and each scene is numbered. Text files are named by chapter number, then scene number, then some text describing the chapter. For example, the third scene in chapter seven is named:

Code:
07_03_Al_Investigates.txt

The chapters by scene are in the chapters/ directory. When the compiler is run it deletes the total/ and book/ directories if they exist, and then recreates them. It writes each scene into it's proper chapter and puts all the chapters into a book. You can give it a title with the "-t" option, or it just calls the book 'Book'.
 
Moved the 2d6_ogl_chargen repo to Makhidkaun from my personal space. Spent part of the day working on simplifying the code so it is easy to add careers. Still a bit of work to do but I'm liking the direction.

Each career has base skills, advanced skills, and muster out benefits. With the new setup those lists are in plain text files and the code slurps them into an array. Someone using the files could easily change the chances of certain skills or add/delete others just by editing the text file.
 
In the 2d6_ogl_chargen repo I added "encounter.rb". Which is really simple code that demonstrates a couple things I enjoy.

The first is pulling stuff from a regular text file. That's pretty portable; a Python coder could grab the same files and use them as they like.

The second is building up from modules. Ruby has "mixins", Python has multiple class inheritance, etc. Basically the blocks are built in a generic "tools" file (character_tools.rb) and then small bits of code like encounter.rb become easier to produce.
 
Added "build_book" as a way to compile text documents, dedications, afterwards, etc, into one volume. Not much in the way of classes or OOP yet, but that's an option to explore. Code that works has its own beauty. :coffeesip:
 
Trying to figure out world building, and the effects of different sizes, etc. Wrote something to help me understand gravity as math is not my strength. In this case it showed the target planet would need to be 2.6-ish times more dense than earth to have close to the same gravity.
 
Added some detail to the planet.rb library. It tends towards habitable planets but you can easily change assumptions as long as you change the min and max usages. While it's written in Ruby any C based language skills should make it easy for you to read.

I'm also working on re-learning RSpec so there's a mildly decent test suite included.
 
Yesterday I poked at Ruby again and made a basic code coverage tool to tell me where I need to add tests.

Okay, I need lots of tests... Here's an example of the output.

Code:
$ test_coverage
Missing Test Case:
  lib/star_systems.rb
  lib/errors.rb
  lib/presenter_csv.rb
  lib/presenter_default.rb
  lib/presenter_sql.rb
  lib/name.rb
  lib/career.rb
  lib/presenter.rb
Missing Tests:
  lib/character.rb
    generate
    init_stuff
    run_career
  lib/planet.rb
    set_trade_codes
  lib/character_tools.rb
    dice
    noble?
    increase_skill
    modify_stat
 
Moving things to new names; "ftl_tools" for the basic stuff and "free_trader" for the game. Moving a lot of things around but they are now published gems.
 
While I recommend using the TravellerMap for data, I wanted to play around with some Ruby and MongoDB. input_planets pulls from a CSV file in the data directory and loads everything into a MongoDB database.
 
Have a look for the TravellerMap APi, it is pretty well written. I was dabbling with moving a ship gif across the map with a view to perhaps representing the movement of fleets or PC ships over time. Think weekly Trillion Credit Squadron intelligence reports.
 
Have a look for the TravellerMap APi, it is pretty well written. I was dabbling with moving a ship gif across the map with a view to perhaps representing the movement of fleets or PC ships over time. Think weekly Trillion Credit Squadron intelligence reports.

Yeah, I had looked at it a while back when I was doing some PHP stuff. The API is very good. Right now, though, I'm working past the edge of my skills and trying to focus on one step at a time. Down the road the "Free Trader" program will read from TravellerMap and let you buy and sell as you go from system to system. I dreamed of doing that when I first started playing four decades ago; time to get back to the dream.
 
Back
Top