· 7 years ago · Sep 17, 2018, 11:18 PM
1#!/usr/bin/python3.6
2# barloovapy001.py
3# coding: utf-8
4#
5# Not much in this version except a few primitive but code-working classes
6#
7# Original program: goshemighty Written in Turbo Pascal 5.5 last edit 01/24/2000
8# Sporadic Python conversion began Aug-27-2018 - doc edits and variable conversion
9# Code conversion began Sep-01-2018 - Entity class (subclass: npc)
10#
11#
12import tkinter as tk # Will be used for the UI
13import random # Used extensively for everything
14import time # Will be used to track player stats, logs, in-game movements, etc. This is LONG term
15# Table of contents
16# Import modules:
17# tkinter = GUI, time = logging/special events, random = everything
18# Global variables:
19# seed,
20# Class definitions:
21# Entity (subclass- Plyr, Npc)
22# Item (nest all tangible items)
23# Functions / Methods:
24# rnd, keys (should transition to ui management)
25#
26# Original program layout:
27# Variable definitions : No longer necessary in original format
28# Functions / Methods:
29# keys, rnd <sets entry to uppercase, random generator>
30# makestats <Sets up the player>
31# final <Endgame scoring>
32# damage <calculate damage, weariness>
33# dostats, seestats, setstats setmap <various game procedures>
34# arm, wpn, trp
35# puzzles (p1-p5)
36# cns, other, pzl
37# smarts, strength, agility, fatigue (* could be compressed to a single *)
38# artfct
39# magic1
40# attacks, enemies
41# playgame
42# setup
43# Actual program
44seed = 12 # Global variable for random number generator
45class Entity: # Top character definition - instances include "p"lyr and "en"emy
46 max = 34; # Max points. Modifies by race, role, gender(m=+1st,f+1iq), age, level(4pts ea.)
47 name = "player"
48 lvl = '0'
49 st = dx = iq = "4" # Primary stats modifies by race
50 moves = 2 # Modifies by race and role
51 race, role = "race", "occupation" # Create race, occupation dictionaries
52 roomnum = 1 # Is this still necessary?
53 weary = 0 # weariness affects movement, pacer, magic, healing, and more.
54 kills = 0 # Total kills in game
55 age = 17 # This is modified during player setup, ranging from 17-45
56 sex = "gender" # gender helps determine basic stats during player setup
57 scr = art = pot = kys = wt = 0 # Main game items, wt equals weight carried
58 curdmg = totdmg = 0 # Current damage and game total accumulated
59 wep, wepdam, wepcon, wepuses = "weapntype", "weapndamage", "Weapncondition", "Number of uses"
60 arm, armdam, armcon, armuses = "armrtype", "armrdamage", "armrcondition", "Number of hits"
61
62class Npc(Entity): # Non playing characters are a subclass of the entity class
63 count = 0 # npcs have to be counted and named, plyr does not.
64 names = []
65
66 def __init__(self, name): # Allows for multiple NPCs in an encounter
67 self.number = Npc.count # Should be set to the number of npcs to create
68 self.name = name # Set up the class here, then call it dynamically
69 Npc.count += 1 # I wonder if the whole class should be dynamic?
70 Npc.names.append(name)
71
72 # This will be random NPC encounter generation. Use and discard as needed
73 l=[]
74 # l.append(Npc("en1")) # This should be part of a -for- or -while- loop
75 # l.append(Npc("en2")) #etc
76 # print l # class instance memory addresses (for testing only)
77 # print l[0].number, l[0].name # how class instances are called
78 # print l[1].number, l[1].name # how class instances are called
79 # print Npc.count, Npc.names # calling class categories
80
81class Items: # Parent container for all "things"
82 # Children include potions, weapons, armor, artifacts, etc)
83 # Begin global item initialization
84 itemnm = "name" # This is redundant as a general name. Make it a proper name? 'The potion <arghsplat>'
85 itmtype = ("weapon", "armor", "artifact", "scroll", "potion", "other") # This is for fast comparisons
86 useon = ("plyr", "npc", "none", "puzzle", "unknown") # In what ways can the item be used?
87 desc = "item description" # A text string. Could be used to indicate approximate condition
88 dxmin = iqmin = stmin = "0" # Minimum stats required to use this item
89 itemwt = '.1' # Item weight. Not yet used. It exists as a future marker
90 numuse = '1' # How many times can this item be used? -1 is infinite
91 is_ranged = False # Can this item be thrown?
92 def __init__(self, name): # Enable instances of Items
93 self.name = name
94 # End global item initialization
95
96
97def rnd(): # Simple random number generator. Seed variable should be global
98 seed = random.randint(1, seed+1)