M
mx2k
Hello @ all,
we have written a small program (code below) for our own
in-developement rpg system, which is getting values for 4
RPG-Characters and doing some calculations with it.
now we're trying hard to find out how to get it working with 'n'
Characters, so you will be asked to enter a number at the beginning,
asking you how many characters you want.
anyone out there who could help us?
also i wonder how i can read the current date/time (we don't understand
datetime() )and put it into a variable and print that variable?
[mx] and Tschabo
doing python since yesterday
Code follows:
# Timeline Tools for an RPG system - Written in Python 2.4
# Created by [mx] networkz @ 27.02.05 - (e-mail address removed)
# Collaboration work of mx2k & Tschabo (von Konsti)
# import math
#-------------------------------------------------------------
#defining functions
#header text
def showtitle():
print ''
print ' Timeline System - Alpha Version 0.8.15 '
print '____________________________________________'
print '* supports 4 characters *'
print '* coding [mx] networkz & Tschabo *'
print '* created 2005 *'
#print '============================================'
print ''
#sorting
def sortfun():
charlist = [char1[1],char2[1],char3[1],char4[1]]
charlist.sort()
#dunno if correct, is spamming move[] lists but working correctly
if charlist[0] == char1[1]:
move1[0:0] = [char1[0],char1[1],char1[2]]
if charlist[0] == char2[1]:
move1[0:0] = [char2[0],char2[1],char2[2]]
if charlist[0] == char3[1]:
move1[0:0] = [char3[0],char3[1],char3[2]]
if charlist[0] == char4[1]:
move1[0:0] = [char4[0],char4[1],char4[2]]
if charlist[1] == char1[1]:
move2[0:0] = [char1[0],char1[1],char1[2]]
if charlist[1] == char2[1]:
move2[0:0] = [char2[0],char2[1],char2[2]]
if charlist[1] == char3[1]:
move2[0:0] = [char3[0],char3[1],char3[2]]
if charlist[1] == char4[1]:
move2[0:0] = [char4[0],char4[1],char4[2]]
if charlist[2] == char1[1]:
move3[0:0] = [char1[0],char1[1],char1[2]]
if charlist[2] == char2[1]:
move3[0:0] = [char2[0],char2[1],char2[2]]
if charlist[2] == char3[1]:
move3[0:0] = [char3[0],char3[1],char3[2]]
if charlist[2] == char4[1]:
move3[0:0] = [char4[0],char4[1],char4[2]]
if charlist[3] == char1[1]:
move4[0:0] = [char1[0],char1[1],char1[2]]
if charlist[3] == char2[1]:
move4[0:0] = [char2[0],char2[1],char2[2]]
if charlist[3] == char3[1]:
move4[0:0] = [char3[0],char3[1],char3[2]]
if charlist[3] == char4[1]:
move4[0:0] = [char4[0],char4[1],char4[2]]
#showing next action times
# should also be enumerated to 'n'th action
# but how to put that into string
def shownextaction():
print 'Loop Nr. ', run_nr
print ''
print '---------------------------------------'
print 'Next action', move1[0], 'at tick No', move1[1]
print ' 2nd action', move2[0], 'at tick No', move2[1]
print ' 3rd action', move3[0], 'at tick No', move3[1]
print ' 4th action', move4[0], 'at tick No', move4[1]
print '---------------------------------------'
#log to textfile
def logfile():
outnr = str('Loop Nr. ') + str(run_nr) + str('\n')
out1 = str(' Next action ') + str(move1[0])+ str(' at tick No ') +
str(move1[1]) + str('\n')
out2 = str(' 2nd action ') + str(move2[0])+ str(' at tick No ') +
str(move2[1]) + str('\n')
out3 = str(' 3rd action ') + str(move3[0])+ str(' at tick No ') +
str(move3[1]) + str('\n')
out4 = str(' 4th action ') + str(move4[0])+ str(' at tick No ') +
str(move4[1]) + str('\n\n')
incr_ = str('Entered Number was: ') + str(inc) + str('\n')
incre = str('Increasing Character ') + str(move1[0]) + str(' by
Value: ') + str(inc) + str(' + ') + str(inc_out) + str('\n\n\n')
#timecode= str
f = file('timeline.txt', 'a')
#f.write(timecode)
f.write('Actiontimes of ')
f.write(outnr)
f.write(out1)
f.write(out2)
f.write(out3)
f.write(out4)
f.write(incr_)
f.write(incre)
f.close()
#-----------------------------------------------------------------------
#defining some stuff, calling title
showtitle()
run_nr= 0
the_end = 'this is the end. exit requested by user.'
loops = int(raw_input("Number of Loops: "))
#check if we should run, then asking for input
# here it should ask for n characters, then enumerating
# variables, i.e. n=6 creates char1-char6 and filling it
# like shown below
if loops == 0:
the_end
else:
char1 = [raw_input("Char 1 Name: "),int(raw_input("Char 1
Initiative: ")),int(raw_input("Char 1 Reaction Time: "))]
char2 = [raw_input("Char 2 Name: "),int(raw_input("Char 2
Initiative: ")),int(raw_input("Char 2 Reaction Time: "))]
char3 = [raw_input("Char 3 Name: "),int(raw_input("Char 3
Initiative: ")),int(raw_input("Char 3 Reaction Time: "))]
char4 = [raw_input("Char 4 Name: "),int(raw_input("Char 4
Initiative: ")),int(raw_input("Char 4 Reaction Time: "))]
move1 = [0,0,0]
move2 = [0,0,0]
move3 = [0,0,0]
move4 = [0,0,0]
#-----------------------------------------------------------------------
#loop the shiznit
if loops == 0:
print the_end
else:
rtd = 1
for rtd in range(loops+1):
#calling sort/show functions
sortfun()
shownextaction()
#increasing value of the smallest
smallest = min(char1[1],char2[1],char3[1],char4[1])
print 'Amount of Actiontime to add for', move1[0]
inc = int(raw_input('Value: '))
print '_______________________________________'
if smallest == char1[1]:
char1[1] = inc + char1[1] + char1[2]
inc_out = char1[2]
if smallest == char2[1]:
char2[1] = inc + char2[1] + char2[2]
inc_out = char2[2]
if smallest == char3[1]:
char3[1] = inc + char3[1] + char3[2]
inc_out = char3[2]
if smallest == char4[1]:
char4[1] = inc + char4[1] + char4[2]
inc_out = char4[2]
#writing to logfile and increasing loop nr
logfile()
run_nr = run_nr + 1
we have written a small program (code below) for our own
in-developement rpg system, which is getting values for 4
RPG-Characters and doing some calculations with it.
now we're trying hard to find out how to get it working with 'n'
Characters, so you will be asked to enter a number at the beginning,
asking you how many characters you want.
anyone out there who could help us?
also i wonder how i can read the current date/time (we don't understand
datetime() )and put it into a variable and print that variable?
[mx] and Tschabo
doing python since yesterday
Code follows:
# Timeline Tools for an RPG system - Written in Python 2.4
# Created by [mx] networkz @ 27.02.05 - (e-mail address removed)
# Collaboration work of mx2k & Tschabo (von Konsti)
# import math
#-------------------------------------------------------------
#defining functions
#header text
def showtitle():
print ''
print ' Timeline System - Alpha Version 0.8.15 '
print '____________________________________________'
print '* supports 4 characters *'
print '* coding [mx] networkz & Tschabo *'
print '* created 2005 *'
#print '============================================'
print ''
#sorting
def sortfun():
charlist = [char1[1],char2[1],char3[1],char4[1]]
charlist.sort()
#dunno if correct, is spamming move[] lists but working correctly
if charlist[0] == char1[1]:
move1[0:0] = [char1[0],char1[1],char1[2]]
if charlist[0] == char2[1]:
move1[0:0] = [char2[0],char2[1],char2[2]]
if charlist[0] == char3[1]:
move1[0:0] = [char3[0],char3[1],char3[2]]
if charlist[0] == char4[1]:
move1[0:0] = [char4[0],char4[1],char4[2]]
if charlist[1] == char1[1]:
move2[0:0] = [char1[0],char1[1],char1[2]]
if charlist[1] == char2[1]:
move2[0:0] = [char2[0],char2[1],char2[2]]
if charlist[1] == char3[1]:
move2[0:0] = [char3[0],char3[1],char3[2]]
if charlist[1] == char4[1]:
move2[0:0] = [char4[0],char4[1],char4[2]]
if charlist[2] == char1[1]:
move3[0:0] = [char1[0],char1[1],char1[2]]
if charlist[2] == char2[1]:
move3[0:0] = [char2[0],char2[1],char2[2]]
if charlist[2] == char3[1]:
move3[0:0] = [char3[0],char3[1],char3[2]]
if charlist[2] == char4[1]:
move3[0:0] = [char4[0],char4[1],char4[2]]
if charlist[3] == char1[1]:
move4[0:0] = [char1[0],char1[1],char1[2]]
if charlist[3] == char2[1]:
move4[0:0] = [char2[0],char2[1],char2[2]]
if charlist[3] == char3[1]:
move4[0:0] = [char3[0],char3[1],char3[2]]
if charlist[3] == char4[1]:
move4[0:0] = [char4[0],char4[1],char4[2]]
#showing next action times
# should also be enumerated to 'n'th action
# but how to put that into string
def shownextaction():
print 'Loop Nr. ', run_nr
print ''
print '---------------------------------------'
print 'Next action', move1[0], 'at tick No', move1[1]
print ' 2nd action', move2[0], 'at tick No', move2[1]
print ' 3rd action', move3[0], 'at tick No', move3[1]
print ' 4th action', move4[0], 'at tick No', move4[1]
print '---------------------------------------'
#log to textfile
def logfile():
outnr = str('Loop Nr. ') + str(run_nr) + str('\n')
out1 = str(' Next action ') + str(move1[0])+ str(' at tick No ') +
str(move1[1]) + str('\n')
out2 = str(' 2nd action ') + str(move2[0])+ str(' at tick No ') +
str(move2[1]) + str('\n')
out3 = str(' 3rd action ') + str(move3[0])+ str(' at tick No ') +
str(move3[1]) + str('\n')
out4 = str(' 4th action ') + str(move4[0])+ str(' at tick No ') +
str(move4[1]) + str('\n\n')
incr_ = str('Entered Number was: ') + str(inc) + str('\n')
incre = str('Increasing Character ') + str(move1[0]) + str(' by
Value: ') + str(inc) + str(' + ') + str(inc_out) + str('\n\n\n')
#timecode= str
f = file('timeline.txt', 'a')
#f.write(timecode)
f.write('Actiontimes of ')
f.write(outnr)
f.write(out1)
f.write(out2)
f.write(out3)
f.write(out4)
f.write(incr_)
f.write(incre)
f.close()
#-----------------------------------------------------------------------
#defining some stuff, calling title
showtitle()
run_nr= 0
the_end = 'this is the end. exit requested by user.'
loops = int(raw_input("Number of Loops: "))
#check if we should run, then asking for input
# here it should ask for n characters, then enumerating
# variables, i.e. n=6 creates char1-char6 and filling it
# like shown below
if loops == 0:
the_end
else:
char1 = [raw_input("Char 1 Name: "),int(raw_input("Char 1
Initiative: ")),int(raw_input("Char 1 Reaction Time: "))]
char2 = [raw_input("Char 2 Name: "),int(raw_input("Char 2
Initiative: ")),int(raw_input("Char 2 Reaction Time: "))]
char3 = [raw_input("Char 3 Name: "),int(raw_input("Char 3
Initiative: ")),int(raw_input("Char 3 Reaction Time: "))]
char4 = [raw_input("Char 4 Name: "),int(raw_input("Char 4
Initiative: ")),int(raw_input("Char 4 Reaction Time: "))]
move1 = [0,0,0]
move2 = [0,0,0]
move3 = [0,0,0]
move4 = [0,0,0]
#-----------------------------------------------------------------------
#loop the shiznit
if loops == 0:
print the_end
else:
rtd = 1
for rtd in range(loops+1):
#calling sort/show functions
sortfun()
shownextaction()
#increasing value of the smallest
smallest = min(char1[1],char2[1],char3[1],char4[1])
print 'Amount of Actiontime to add for', move1[0]
inc = int(raw_input('Value: '))
print '_______________________________________'
if smallest == char1[1]:
char1[1] = inc + char1[1] + char1[2]
inc_out = char1[2]
if smallest == char2[1]:
char2[1] = inc + char2[1] + char2[2]
inc_out = char2[2]
if smallest == char3[1]:
char3[1] = inc + char3[1] + char3[2]
inc_out = char3[2]
if smallest == char4[1]:
char4[1] = inc + char4[1] + char4[2]
inc_out = char4[2]
#writing to logfile and increasing loop nr
logfile()
run_nr = run_nr + 1