Advertisement
Guest User

RandoTK 1.06

a guest
Jul 27th, 2015
433
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 37.61 KB | None | 0 0
  1. # -*- encoding:Latin-1 -*-
  2. #THIS PROGRAM CREATES RANDOM SCENARIOS FOR ROTK11
  3. #RandOTK11 v1.06
  4. #
  5. #
  6. # IMPORTING WIDGETS AND DEFINING VARIABLES
  7. #
  8. import os
  9. from random import *
  10. from tkinter import *
  11. from tkinter import messagebox
  12. from tkinter.filedialog import *
  13. chk = b'KOEI%SAN11'
  14. authorized_filesizes = [167559, 169822, 179109, 167371]
  15. helptext = "RandOTK11 v1.06\n\n Information : This program randomizes Romance of the Three Kingdoms XI Scenario Files (.S11 extension) and has been developed in Python by 'Zetta' \n More information on the forums of http://the-scholars.com/"
  16. #
  17. # DEFINE FUNCTIONS
  18. #
  19. # TICK / UNTICK CHECKBOXES FUNCTIONS
  20. #
  21. def ForceNoNewO():
  22.   global NewOVar,TiesVar
  23.   if TiesVar.get()==0 and NewOVar.get()==1:
  24.     NewOVar.set(0)
  25. def ForceTies():
  26.   global NewOVar,TiesVar
  27.   if NewOVar.get()==1:
  28.     TiesVar.set(1)
  29. #
  30. # CREATE RANDOM OFFICER FUNCTION
  31. #
  32. def NewOfficer(sdate):
  33.   sex = choice([0,1])
  34.   birth = sdate - randrange(5,31)
  35.   avail = birth + randrange(15,29)
  36.   death = birth + randrange(30,99)
  37.   growth = randrange(0,8)
  38.   skill = choice([255, randrange(0,100)])
  39.   status = 7
  40.   if avail>sdate:
  41.     status = 6
  42.   if sex==0:
  43.     face = randrange(2000,2100)
  44.     voice = randrange(0,4)
  45.     tone = choice([6,8,9,10,11,12,13,14,15])
  46.   if sex==1:
  47.     face = randrange(2100,2175)
  48.     voice = randrange(4,6)
  49.     tone = choice([6,9,10,14,15])
  50.   Officer = [face%256, face//256, sex, avail%256, avail//256, birth%256, birth//256, death%256, death//256, randrange(0,2), 255,255,255,255,255,255,1,255,255,255,255, randrange(1,150),255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 255, randrange(0,42), 0, randrange(0,42), 0, status, 50, 255, 255, 0,0,0, randrange(0,3),randrange(0,3),randrange(0,3),randrange(0,3),randrange(0,3),randrange(0,3), randrange(30,70), randrange(30,70), randrange(30,70), randrange(30,70), randrange(30,70), growth,growth,growth,growth,growth, randrange(0,12), skill, randrange(0,3), randrange(0,5), randrange(0,5), randrange(0,5), randrange(0,4), voice, tone, randrange(0,3), randrange(0,3), randrange(0,3), sex, 84,84,84,255,84,84,255,255,255,255,255,255,0,0,0,0]
  51.   return(Officer)
  52. #
  53. # RANDOM STATS FUNCTION
  54. #
  55. def RandomStats():
  56.   f1 = choice([1,1,1,2,2,3,3,3,3,4,4,4,4,5,5,5,6,6,6,6])
  57. # defining 4 types of random officers : 1 is hero, 2 is strategist, 3 is general, 4 is civil official, 5 is standard and 6 is random
  58.   if f1==1:
  59.     f = [randrange(1,4), randrange(1,4), randrange(1,4),randrange(1,4),randrange(1,4), randrange(1,4), randrange(70,101), randrange(70,101), randrange(70,101), randrange(70,101), randrange(70,101)]
  60.   if f1==2:
  61.     f = [randrange(0,3), randrange(0,3), randrange(1,4),randrange(0,4),randrange(1,4), randrange(1,4), randrange(50,96), randrange(50,76), randrange(75,101), randrange(75,101), randrange(75,101)]
  62.   if f1==3:
  63.     f = [randrange(0,4), randrange(0,4), randrange(0,4),randrange(0,4),randrange(0,4), randrange(0,4), randrange(80,98), randrange(80,98), randrange(40,81), randrange(40,81), randrange(80,94)]
  64.   if f1==4:
  65.     f = [randrange(0,3), randrange(0,3), randrange(0,3),randrange(0,3),randrange(0,3), randrange(0,3), randrange(5,66), randrange(5,66), randrange(60,86), randrange(60,86), randrange(40,86)]
  66.   if f1==5:
  67.     f = [randrange(0,3), randrange(0,3), randrange(0,3),randrange(0,3),randrange(0,3), randrange(0,3), randrange(20,61), randrange(20,61), randrange(20,61), randrange(20,61), randrange(20,61)]
  68.   if f1==6:
  69.     f = [randrange(0,4), randrange(0,4), randrange(0,4),randrange(0,4),randrange(0,4), randrange(0,4), randrange(1,101), randrange(1,101), randrange(1,101), randrange(1,101), randrange(1,101)]
  70.   return(f)
  71. #
  72. # DEFINE HELP / INFO FUNCTION
  73. #
  74. def info():
  75.   global helptext
  76.   messagebox.showinfo("Help", helptext)
  77. #
  78. # DEFINE EXIT FUNCTION
  79. #
  80. def exitrandotk():
  81.   global window
  82.   try:
  83.     Scen.close()
  84.   except:
  85.     pass
  86.   window.destroy()
  87. #
  88. # DEFINE OPEN FILE FUNCTION
  89. #
  90. def openSCEN():
  91.   global Scen,File,Filesize
  92.   File = askopenfilename(defaultextension = ".S11", filetypes = [("S11","*.S11")])
  93.   try:
  94.     Scen = open(File, "rb+")
  95.     Scen.seek(8,0)
  96.     f = Scen.read(10)
  97.     Filesize = os.path.getsize(File)
  98.     if chk == f and Filesize in authorized_filesizes:
  99.       randbtn.config(state = ACTIVE)
  100.     if chk != f or Filesize not in authorized_filesizes:
  101.       print("ERROR: chosen file is not a ROTK11 scenario file")
  102.       Scen.close()
  103.       randbtn.config(state = DISABLED)
  104.   except:
  105.     print("No File selected")
  106.     randbtn.config(state = DISABLED)
  107. #
  108. #
  109. # DEFINE RANDOMIZE FUNCTION
  110. #
  111. #
  112. def Randomize():
  113.   global a,b,c,d,e,f,x,y,IA,equi,res,HistVar,rdoff,fnum,LifeVar,CityVar,AllyVar,Filesize,TiesVar
  114.   randbtn.config(state = DISABLED)
  115.   leaders = [16, 17, 18, 20, 50, 65, 91, 101, 105, 109, 120, 129, 149, 160, 180, 182, 184, 190, 225, 263, 288, 328, 343, 347, 349, 350, 358, 362, 365, 367, 370, 383, 403, 415, 431, 435, 442, 465, 484, 493, 515, 517, 568, 598, 614, 618, 624, 629, 631, 632, 635, 636, 660]
  116.   colors = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41]
  117.   cities = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41]
  118.   nghb = [[1], [0,2,3], [1,3,5], [1,2,4], [3,6,7,11], [2,6], [4,5,11,12], [4,8,9,11], [7,9], [7,8,10,11,12], [9,14,25], [4,6,7,9,12], [6,9,11,13,15,16], [12,14,16,28], [10,13,28], [12,16,17], [12,13,15,17,18,28], [15,16,19,20,36], [16,29,36], [17,20,21], [17,19,21,36], [19,20], [23,25], [22,24], [23], [10,22,26,27], [25,27,30,31], [25,26,28,30], [13,14,16,27,29], [18,28,30,35], [26,27,29,31,32,35], [26,30,32,33], [30,31,34], [31,34], [32,33], [29,30,38], [17,18,20,37], [36,39], [35,39,40], [37,38], [38,41], [40]]
  119.   gates = [[10], [], [], [], [11], [0,12], [13], [14,15], [16,17], [], [18], [19], [20], [], [], [1,21,22], [], [23,2,3,4], [25], [], [], [], [26,27], [28], [29], [30], [31,32,33,34], [35], [36], [37], [38,39,40], [41], [42,43], [], [], [44], [5], [6,7], [], [8,9], [], []]
  120.   forces = []
  121. #
  122. # PREPARING A BLANK SCENARIO BY DEFAULT
  123. #
  124. # SCENARIO NAME AND DESCRIPTION
  125. #
  126.   if Filesize ==179109:
  127.     sname = b'Random\x20Scenario'
  128.     Scen.seek(95,0)
  129.     Scen.write(sname)
  130.     Scen.write(bytes(5))
  131.     Scen.seek(121,0)
  132.     Scen.write(bytes(450))
  133. #
  134. # BLANK MAP PREVIEW
  135. #
  136.   if Filesize==179109:
  137.     Scen.seek(722,0)
  138.   if Filesize==169822:
  139.     Scen.seek(475,0)
  140.   if Filesize==167559 or Filesize==167371:
  141.     Scen.seek(418,0)
  142.   Scen.write(42*bytes([255]))
  143. #
  144. # BLANK FORCES DESCRIPTION
  145. #
  146.   if Filesize==179109:
  147.     x = 0
  148.     while x<42:
  149.       Scen.seek(932+x*607,0)
  150.       Scen.write(bytes([0,20]))
  151.       Scen.write(bytes(605))
  152.       x+=1
  153. #
  154. # OFFICERS BLANK
  155. #
  156.   x = 0
  157.   while x<670:
  158.     if Filesize==179109:
  159.       Scen.seek(28098+x*152, 0)
  160.     if Filesize==169822:
  161.       Scen.seek(17855+x*152, 0)
  162.     if Filesize==167559 or Filesize==167371:
  163.       Scen.seek(15404+x*152, 0)
  164.     Scen.write(bytes([255]))
  165.     a = [randrange(0,42),0]
  166.     Scen.write(bytes(a))
  167.     Scen.write(bytes(a))
  168.     y = choice([4,7,7,7])
  169.     Scen.write(bytes([y]))
  170.     Scen.write(b"\x50")
  171.     if Filesize==179109:
  172.       Scen.seek(28107+x*152, 0)
  173.     if Filesize==169822:
  174.       Scen.seek(17864+x*152, 0)
  175.     if Filesize==167559 or Filesize==167371:
  176.       Scen.seek(15413+x*152, 0)
  177.     Scen.write(bytes(3))
  178. # TIES CUTTER OPTION
  179.     if TiesVar.get()==1:
  180.       if Filesize==179109:
  181.         Scen.seek(28068+x*152, 0)
  182.       if Filesize==169822:
  183.         Scen.seek(17825+x*152, 0)
  184.       if Filesize==167559 or Filesize==167371:
  185.         Scen.seek(15374+x*152, 0)
  186.       Scen.write(bytes([255,255,255,255]))
  187.       Scen.seek(1, 1)
  188.       Scen.write(bytes([255,255,255,255]))
  189. # NEXT OFFICER
  190.     x+=1
  191. #
  192. # FORCE SLOTS BLANK
  193. #
  194.   y = 0
  195.   while y<42:
  196.     L = [255,255,255,255]
  197.     L.extend([50]*y)
  198.     L.extend([100])
  199.     L.extend((41-y)*[50])
  200.     if Filesize==179109:
  201.       Scen.seek(160603+y*68, 0)
  202.     if Filesize==169822:
  203.       Scen.seek(152660+y*68, 0)
  204.     if Filesize==167559:
  205.       Scen.seek(150209+y*72, 0)
  206.     if Filesize==167371:
  207.       Scen.seek(150209+y*68, 0)
  208.     Scen.write(bytes(L))
  209.     Scen.write(bytes(5))
  210.     Scen.write(bytes([9, 255, y, 255, 255]))
  211.     Scen.write(bytes(12))
  212.     y+=1
  213. #
  214. # DISTRICTS BLANK
  215. #
  216.   y = 0
  217.   while y<42:
  218.     L = [255,00,255,255,255,255,255,255]
  219.     if Filesize==179109:
  220.       Scen.seek(163799+y*8, 0)
  221.     if Filesize==169822:
  222.       Scen.seek(155856+y*8, 0)
  223.     if Filesize==167559:
  224.       Scen.seek(153593+y*8, 0)
  225.     if Filesize==167371:
  226.       Scen.seek(153405+y*8, 0)
  227.     Scen.write(bytes(L))
  228.     y+=1
  229. #
  230. # CITIES BLANK
  231. #
  232.   y = 42
  233.   while y:
  234.     y-=1
  235. #set ownership to free
  236.     if Filesize==179109:
  237.       Scen.seek(164175+y*81, 0)
  238.     if Filesize==169822:
  239.       Scen.seek(156232+y*81, 0)
  240.     if Filesize==167559:
  241.       Scen.seek(153969+y*81, 0)
  242.     if Filesize==167371:
  243.       Scen.seek(153781+y*81, 0)
  244.     Scen.write(b"\xff")
  245. # set all equipments to 0
  246.     if Filesize==179109:
  247.       Scen.seek(164179+y*81, 0)
  248.     if Filesize==169822:
  249.       Scen.seek(156236+y*81, 0)
  250.     if Filesize==167559:
  251.       Scen.seek(153973+y*81, 0)
  252.     if Filesize==167371:
  253.       Scen.seek(153785+y*81, 0)
  254.     Scen.write(bytes(61))
  255. #CITY REVENUE AND HARVEST RANDOMIZER
  256.     if RevHarVar.get()==1:
  257.       Scen.seek(2,1)
  258.       revenue = 100*randrange(3,8)
  259.       harvest = 1000*randrange(4,9)
  260.       Scen.write(bytes([revenue%256, revenue//256, harvest%256, harvest//256]))
  261. # set will and order to 0 and 50
  262.     if Filesize==179109:
  263.       Scen.seek(164248+y*81, 0)
  264.     if Filesize==169822:
  265.       Scen.seek(156305+y*81, 0)
  266.     if Filesize==167559:
  267.       Scen.seek(154042+y*81, 0)
  268.     if Filesize==167371:
  269.       Scen.seek(153854+y*81, 0)
  270.     Scen.write(b"\x00"+b"\x32")
  271. #CITY SPECIALTY RANDOMIZER
  272.     if CitySpeVar.get()==1:
  273.       specity = [[0,0,0,0,0,0], [1,0,0,0,0,0], [0,1,0,0,0,0], [0,0,1,0,0,0], [0,0,0,1,0,0], [0,0,0,0,1,0], [0,0,0,0,0,1]]
  274.       Scen.write(bytes(choice(specity)))
  275. #
  276. #GATES AND PORTS BLANK
  277. #
  278.   y = 45
  279.   while y:
  280.     y-=1
  281.     if Filesize==179109:
  282.       Scen.seek(167577+y*64, 0)
  283.     if Filesize==169822:
  284.       Scen.seek(159634+y*64, 0)
  285.     if Filesize==167559:
  286.       Scen.seek(157371+y*64, 0)
  287.     if Filesize==167371:
  288.       Scen.seek(157183+y*64, 0)
  289.     Scen.write(b"\xff")
  290.     Scen.write(bytes(61))
  291.   print("Scenario has been made blank for preparation.")
  292. #
  293. #
  294. # THIS IS THE STARTING PART OF THE RANDOMIZER
  295. # SETUP STARTING DATE SELECTION
  296. #
  297.   try:
  298.     sdate = int(SdateEntry.get())
  299.     if sdate<170 or sdate>351:
  300.       sdate = randrange(170,350)
  301.   except:
  302.     sdate = randrange(170,350)
  303.   w = [sdate%256, sdate//256, randrange(0,13)]
  304.   Scen.seek(91, 0)
  305.   Scen.write(bytes(w))
  306.   if Filesize==179109:
  307.     Scen.seek(26427, 0)
  308.   if Filesize==169822:
  309.     Scen.seek(16184, 0)
  310.   if Filesize==167559 or Filesize==167371:
  311.     Scen.seek(13733, 0)
  312.   Scen.write(bytes(w))
  313. #
  314. # OFFICERS UPDATE AND CREATION OF A LIST OF FREE OFFICERS
  315. #
  316.   TotalNewOff = 0
  317.   x = 0
  318.   offi = []
  319.   while x<670:
  320.     if Filesize==179109:
  321.       Scen.seek(28059+x*152, 0)
  322.     if Filesize==169822:
  323.       Scen.seek(17816+x*152, 0)
  324.     if Filesize==167559 or Filesize==167371:
  325.       Scen.seek(15365+x*152, 0)
  326.     avail = ord(Scen.read(1)) + 256*ord(Scen.read(1))
  327.     birth = ord(Scen.read(1)) + 256*ord(Scen.read(1))
  328. #
  329.     if LifeVar.get()==1:
  330.       deathd = birth + randrange(30,100)
  331.       Scen.write(bytes([deathd%256, deathd//256]))
  332.       if Filesize==179109:
  333.         Scen.seek(28059+x*152, 0)
  334.       if Filesize==169822:
  335.         Scen.seek(17816+x*152, 0)
  336.       if Filesize==167559 or Filesize==167371:
  337.         Scen.seek(15365+x*152, 0)
  338.       avail = birth + randrange(15,29)
  339.       Scen.write(bytes([avail%256, avail//256]))
  340.     if LifeVar.get()==0:
  341.       deathd = ord(Scen.read(1)) + 256*ord(Scen.read(1))
  342. #
  343.     if Filesize==179109:
  344.       Scen.seek(28103+x*152, 0)
  345.     if Filesize==169822:
  346.       Scen.seek(17860+x*152, 0)
  347.     if Filesize==167559 or Filesize==167371:
  348.       Scen.seek(15409+x*152, 0)
  349.     if sdate > deathd:
  350.       if NewOVar.get()==0:
  351.         Scen.write(b"\x08")
  352. #
  353. # NEW OFFICER CREATOR
  354. #
  355.       if NewOVar.get()==1 and TotalNewOff<175:
  356.         names1 = [b'Ling', b'Liu', b'Pan', b'Ding', b'Xue', b'Li', b'Meng', b'Ma', b'Bai', b'Tang', b'Mu', b'Shi', b'Xie', b'Wei', b'Zhu', b'Cai', b'Guo', b'Du', b'Tong', b'Zhang', b'Jiang']
  357.         names2 = [b'Song', b'Tong', b'Kui', b'Xuan', b'Qing', b'Fei', b'Ying', b'Sheng', b'Da', b'Bao', b'Yun', b'Zhong', b'Xiu', b'Lin', b'Rui', b'Zhen', b'Li', b'Qian', b'Hong', b'Chao', b'Jing']
  358.         if Filesize==179109:
  359.           Scen.seek(28003+x*152, 0)
  360.           Scen.write(choice(names1))
  361.           Scen.write(bytes(15))
  362.           Scen.seek(28015+x*152, 0)
  363.           Scen.write(choice(names2))
  364.           Scen.seek(28056+x*152, 0)
  365.         if Filesize==169822:
  366.           Scen.seek(17813+x*152, 0)
  367.         if Filesize==167559 or Filesize==167371:
  368.           Scen.seek(15362+x*152, 0)
  369.         NewRandomOfficer = NewOfficer(sdate)
  370.         Scen.write(bytes(NewRandomOfficer))
  371.         if Filesize==179109:
  372.           Scen.seek(28110+x*152,0)
  373.         if Filesize==169822:
  374.           Scen.seek(17867+x*152,0)
  375.         if Filesize==167559 or Filesize==167371:
  376.           Scen.seek(15416+x*152,0)
  377.         Scen.write(bytes(RandomStats()))
  378.         TotalNewOff +=1
  379. #...
  380.       if x in leaders:
  381.         leaders.remove(x)
  382.     if sdate < avail:
  383.       Scen.write(b"\x06")
  384.       if x in leaders:
  385.         leaders.remove(x)
  386.     if avail<=sdate<deathd:
  387.       offi.append(x)
  388.     x+=1
  389.   totaloff = len(offi)
  390. #
  391. # EMPEROR UPDATE
  392. #
  393.   if sdate>189:
  394.     if Filesize==179109:
  395.       Scen.seek(26431,0)
  396.       Scen.write(bytes([190,2]))
  397.       Scen.seek(134503, 0)
  398.       Scen.write(bytes([8]))
  399.       Scen.seek(134503+152, 0)
  400.       Scen.write(bytes([8]))
  401.       Scen.seek(134503+2*152, 0)
  402.       Scen.write(bytes([255]))
  403.     if Filesize==169822:
  404.       Scen.seek(16188,0)
  405.       Scen.write(bytes([190,2]))
  406.       Scen.seek(124260, 0)
  407.       Scen.write(bytes([8]))
  408.       Scen.seek(124260+152, 0)
  409.       Scen.write(bytes([8]))
  410.       Scen.seek(124260+2*152, 0)
  411.       Scen.write(bytes([255]))
  412.     if Filesize==167559 or Filesize==167371:
  413.       Scen.seek(13737,0)
  414.       Scen.write(bytes([190,2]))
  415.       Scen.seek(121809, 0)
  416.       Scen.write(bytes([8]))
  417.       Scen.seek(121809+152, 0)
  418.       Scen.write(bytes([8]))
  419.       Scen.seek(121809+2*152, 0)
  420.       Scen.write(bytes([255]))
  421.   if sdate<=189:
  422.     if Filesize==179109:
  423.       Scen.seek(26431,0)
  424.       Scen.write(bytes([188,2]))
  425.       Scen.seek(134503, 0)
  426.       Scen.write(bytes([255]))
  427.       Scen.seek(134503+152, 0)
  428.       Scen.write(bytes([8]))
  429.       Scen.seek(134503+2*152, 0)
  430.       Scen.write(bytes([255]))
  431.     if Filesize==169822:
  432.       Scen.seek(16188,0)
  433.       Scen.write(bytes([188,2]))
  434.       Scen.seek(124260, 0)
  435.       Scen.write(bytes([255]))
  436.       Scen.seek(124260+152, 0)
  437.       Scen.write(bytes([8]))
  438.       Scen.seek(124260+2*152, 0)
  439.       Scen.write(bytes([255]))
  440.     if Filesize==167559 or Filesize==167371:
  441.       Scen.seek(13737,0)
  442.       Scen.write(bytes([188,2]))
  443.       Scen.seek(121809, 0)
  444.       Scen.write(bytes([255]))
  445.       Scen.seek(121809+152, 0)
  446.       Scen.write(bytes([8]))
  447.       Scen.seek(121809+2*152, 0)
  448.       Scen.write(bytes([255]))
  449. #
  450. # RANDOMIZER OFFICER STATS - APT - SKILL
  451. #
  452.   if rdoff.get()==1:
  453.     x = 0
  454.     while x<670:
  455.       if Filesize==179109:
  456.         Scen.seek(28110+x*152,0)
  457.       if Filesize==169822:
  458.         Scen.seek(17867+x*152,0)
  459.       if Filesize==167559 or Filesize==167371:
  460.         Scen.seek(15416+x*152,0)
  461.       f = RandomStats()
  462.       Scen.write(bytes(f))
  463.       if Filesize==179109:
  464.         Scen.seek(28127+x*152,0)
  465.       if Filesize==169822:
  466.         Scen.seek(17884+x*152,0)
  467.       if Filesize==167559 or Filesize==167371:
  468.         Scen.seek(15433+x*152,0)
  469.       f2 = 255
  470.       if f[6]>=50 or f[8]>=50:
  471.         f2 = choice([255, randrange(0,100)])
  472.       if f[9]>=70 or f[10]>=70:
  473.         f2 = choice([255, randrange(72,100)])
  474.       if f[9]>=85 or f[10]>=85:
  475.         f2 = choice([randrange(72,100)])
  476.       if f[6]>=70 or f[7]>=70:
  477.         f2 = choice([255, randrange(0,51)])
  478.       if f[6]>=85 or f[7]>=85:
  479.         f2 = randrange(0,51)
  480.       if f[8]>=85:
  481.         f2 = randrange(52,71)
  482.       Scen.write(bytes([f2]))
  483.       x+=1
  484. #
  485. # RANDOMIZER OFFICER LIKED/DISLIKED
  486. #
  487.   if LikeVar.get()==1:
  488.     x = 0
  489.     while x<670:
  490.       x2 = []
  491.       x1 = sample(range(0,670),10)
  492.       for value in x1:
  493.         if value!=x:
  494.           x2.append(value%256)
  495.           x2.append(value//256)
  496.         if value==x:
  497.           x2.append(255)
  498.           x2.append(255)
  499.       if Filesize==179109:
  500.         Scen.seek(28078+x*152,0)
  501.       if Filesize==169822:
  502.         Scen.seek(17835+x*152,0)
  503.       if Filesize==167559 or Filesize==167371:
  504.         Scen.seek(15384+x*152,0)
  505.       Scen.write(bytes(x2))
  506.       x+=1
  507. #
  508. # SETUP FOR NUMBER OF FORCES
  509. #
  510.   try:
  511.     fnum = int(FnumEntry.get())
  512.   except:
  513.     fnum = randrange(2,43)
  514.   if fnum>42 or fnum<2:
  515.     fnum = randrange(2,43)
  516.   print("There is " + str(len(offi)) + " officers available at year " + str(sdate) + " in this scenario.")
  517. #
  518. # REMOVE LEADERS FROM OFFICERS LIST
  519. #
  520.   if HistVar.get()==1:
  521.     for n in leaders:
  522.       try:
  523.         offi.remove(n)
  524.       except:
  525.         print(" \n ERROR : Could not remove officer from list \n")
  526. #
  527. # REMOVE FIXED NUMBER OF FREE CITIES
  528. #
  529.   try:
  530.     freecities = int(FcityEntry.get())
  531.     if freecities>40 or freecities+fnum>42:
  532.       freecities = 42 - fnum
  533.   except:
  534.     if fnum<41:
  535.       freecities = randrange(0,41-fnum)
  536.     if fnum==41:
  537.       freecities = 0
  538.   while freecities>0:
  539.     cities.remove(choice(cities))
  540.     freecities-=1
  541.   avcity = len(cities)
  542. #
  543. # CODE FOR CREATION OF EACH RANDOM FORCE
  544. #
  545. # NOTE : b is force number being created, a is leader, d is capital and c is force color
  546. # e is list of owned cities and f and n are integers for various uses
  547. #
  548. #
  549. # CHOOSE A RULER FROM HISTORICAL OR OFFICERS LIST
  550. #
  551.   leaderslist = []
  552.   b=0
  553.   while b<fnum and offi and len(cities):
  554.     if HistVar.get()!=1 or not len(leaders):
  555.       a = offi[randrange(0,len(offi))]
  556.       offi.remove(a)
  557.     if HistVar.get()==1 and len(leaders):
  558.       a = leaders[randrange(0,len(leaders))]
  559.       leaders.remove(a)
  560.     leaderslist.append(a)
  561. #
  562. # MODIFY LEADER ATTRIBUTES
  563. #
  564.     if Filesize==179109:
  565.       Scen.seek(28098+a*152, 0)
  566.     if Filesize==169822:
  567.       Scen.seek(17855+a*152, 0)
  568.     if Filesize==167559 or Filesize==167371:
  569.       Scen.seek(15404+a*152, 0)
  570.     Scen.write(bytes([b]))
  571.     e = []
  572.     d = choice(cities)
  573.     e.append(d)
  574.     cities.remove(d)
  575.     Scen.write(bytes([d]))
  576.     Scen.write(bytes(1))
  577.     Scen.write(bytes([d]))
  578.     Scen.write(bytes(2))
  579.     if Filesize==179109:
  580.       Scen.seek(28107+a*152, 0)
  581.     if Filesize==169822:
  582.       Scen.seek(17864+a*152, 0)
  583.     if Filesize==167559 or Filesize==167371:
  584.       Scen.seek(15413+a*152, 0)
  585.     Scen.write(bytes([100]))
  586. #
  587. # CREATE FORCE
  588. #
  589.     c = colors[randrange(0,len(colors))]
  590.     forces.append(c)
  591.     colors.remove(c)
  592.     if Filesize==179109:
  593.       Scen.seek(160603+c*68, 0)
  594.     if Filesize==169822:
  595.       Scen.seek(152660+c*68, 0)
  596.     if Filesize==167559:
  597.       Scen.seek(150209+c*72, 0)
  598.     if Filesize==167371:
  599.       Scen.seek(150209+c*68, 0)
  600.     Scen.write(bytes([a%256]))
  601.     Scen.write(bytes([a//256]))
  602. #
  603. # FORCE IA BEHAVIOR
  604. #
  605.     if Filesize==179109:
  606.       Scen.seek(160657+68*c,0)
  607.     if Filesize==169822:
  608.       Scen.seek(152714+68*c,0)
  609.     if Filesize==167559:
  610.       Scen.seek(150263+72*c,0)
  611.     if Filesize==167371:
  612.       Scen.seek(150263+68*c, 0)
  613.     f = 0
  614.     if IA.get()==1:
  615.       f = 0
  616.     if IA.get()==2:
  617.       f = randrange(1,3)
  618.     if IA.get()==3:
  619.       f = randrange(0,6)
  620.     Scen.write(bytes([f]))
  621.     if f==1:
  622.       Scen.write(bytes([randrange(0,6)]))
  623.     if f==2:
  624.       Scen.write(bytes([randrange(0,12)]))
  625.     if f==0 or f==3 or f==4 or f==5:
  626.       Scen.write(bytes([255]))
  627. #
  628. # CREATE FORCE DISTRICT
  629. #
  630.     if Filesize==179109:
  631.       Scen.seek(163799+b*8, 0)
  632.     if Filesize==169822:
  633.       Scen.seek(155856+b*8, 0)
  634.     if Filesize==167559:
  635.       Scen.seek(153593+b*8, 0)
  636.     if Filesize==167371:
  637.       Scen.seek(153405+b*8, 0)
  638.     Scen.write(bytes([c]))
  639.     Scen.write(bytes([1]))
  640.     Scen.write(bytes([a%256]))
  641.     Scen.write(bytes([a//256]))
  642.     obk = choice([1,2])
  643.     if obk ==1:
  644.       Scen.write(bytes([1]))
  645.       Scen.write(bytes([randrange(0,6)]))
  646.     if obk ==2:
  647.       Scen.write(bytes([2]))
  648.       Scen.write(bytes([randrange(0,12)]))
  649. #
  650. # CITY ASSIGNMENT
  651. #
  652.     if Filesize==179109:
  653.       Scen.seek(164175+d*81, 0)
  654.     if Filesize==169822:
  655.       Scen.seek(156232+d*81, 0)
  656.     if Filesize==167559:
  657.       Scen.seek(153969+d*81, 0)
  658.     if Filesize==167371:
  659.       Scen.seek(153781+d*81, 0)
  660.     Scen.write(bytes([b]))
  661.     if equi.get()==4:
  662.       equi.set(randrange(1,4))
  663.     if equi.get()==1:
  664.       f = int(len(cities)/fnum)
  665.     if equi.get()==2:
  666.       try:
  667.         f = randrange(0,len(cities)-fnum+b)
  668.       except:
  669.         f = 0
  670.     if equi.get()==3:
  671.       f = 0
  672.     while f>0:
  673.       if CityVar.get()==1:
  674.         for q in e:
  675.           for r in nghb[q]:
  676.             if r in cities and f>0:
  677.               e.append(r)
  678.               cities.remove(r)
  679.               f-=1
  680.             else:
  681.               f-=1
  682.       if CityVar.get()==0:
  683.         try:
  684.           r = choice(cities)
  685.           e.append(r)
  686.           cities.remove(r)
  687.         except:
  688.           print("Error : could not distribute more cities in non-neighbour cities setup")
  689.         f-=1
  690. #
  691. # EQUIP CITY TROOPS GOLD AND FOOD
  692. #
  693.     for n in e:
  694.       if Filesize==179109:
  695.         Scen.seek(164175+n*81, 0)
  696.       if Filesize==169822:
  697.         Scen.seek(156232+n*81, 0)
  698.       if Filesize==167559:
  699.         Scen.seek(153969+n*81, 0)
  700.       if Filesize==167371:
  701.         Scen.seek(153781+n*81, 0)
  702.       Scen.write(bytes([b]))
  703. #
  704.       Scen.seek(4, 1)
  705.       f = 500*randrange(30,91)
  706.       Scen.write(bytes([f%256, f//256, 0, 0]))
  707. #
  708.       f = 500*randrange(4,15)
  709.       Scen.write(bytes([f%256, f//256, 0, 0]))
  710. #
  711.       f = 1000*randrange(30,66)
  712.       Scen.write(bytes([f%256, f//256, 0, 0]))
  713. #
  714. # EQUIP CITY WEAPONS
  715. #
  716.       if Filesize==179109:
  717.         Scen.seek(164196+n*81, 0)
  718.       if Filesize==169822:
  719.         Scen.seek(156253+n*81, 0)
  720.       if Filesize==167559:
  721.         Scen.seek(153990+n*81, 0)
  722.       if Filesize==167371:
  723.         Scen.seek(153802+n*81, 0)
  724.       f = 1000*randrange(0,6)
  725.       Scen.write(bytes([f%256, f//256, 0, 0]))
  726. #
  727.       f = 1000*randrange(0,6)
  728.       Scen.write(bytes([f%256, f//256, 0, 0]))
  729. #
  730.       f = 1000*randrange(0,6)
  731.       Scen.write(bytes([f%256, f//256, 0, 0]))
  732. #
  733.       f = 1000*randrange(0,6)
  734.       Scen.write(bytes([f%256, f//256, 0, 0]))
  735. #
  736. # SET CITY WILL AND ORDER
  737. #
  738.       if Filesize==179109:
  739.         Scen.seek(164248+n*81, 0)
  740.       if Filesize==169822:
  741.         Scen.seek(156305+n*81, 0)
  742.       if Filesize==167559:
  743.         Scen.seek(154042+n*81, 0)
  744.       if Filesize==167371:
  745.         Scen.seek(153854+n*81, 0)
  746.       f = 5*randrange(12,19)
  747.       Scen.write(bytes([f]))
  748.       f = 5*randrange(12,19)
  749.       Scen.write(bytes([f]))
  750. #
  751. # OFFICERS ASSIGNMENT
  752. #
  753.     for n in e:
  754.       try:
  755.         f = randrange(2,1+round(totaloff/41))
  756.       except:
  757.         f = 2
  758.       while f and len(offi)>fnum:
  759.         q = choice(offi)
  760.         if Filesize==179109:
  761.           Scen.seek(28098+q*152, 0)
  762.         if Filesize==169822:
  763.           Scen.seek(17855+q*152, 0)
  764.         if Filesize==167559 or Filesize==167371:
  765.           Scen.seek(15404+q*152, 0)
  766.         Scen.write(bytes([b]))
  767.         Scen.write(bytes([n]))
  768.         Scen.write(bytes(1))
  769.         Scen.write(bytes([n]))
  770.         Scen.write(bytes(1))
  771.         Scen.write(bytes([3]))
  772.         if Filesize==179109:
  773.           Scen.seek(28107+q*152, 0)
  774.         if Filesize==169822:
  775.           Scen.seek(17864+q*152, 0)
  776.         if Filesize==167559 or Filesize==167371:
  777.           Scen.seek(15413+q*152, 0)
  778.         Scen.write(bytes([randrange(70,100)]))
  779.         offi.remove(q)
  780.         f-=1
  781. #
  782. # MAP PREVIEW
  783. #
  784.     for q in e:
  785.       if Filesize==179109:
  786.         Scen.seek(722+q,0)
  787.       if Filesize==169822:
  788.         Scen.seek(475+q,0)
  789.       if Filesize==167559 or Filesize==167371:
  790.         Scen.seek(418+q,0)
  791.       Scen.write(bytes([c]))
  792. #
  793. # FORCE RANK/TITLE
  794. #
  795.     f = len(e)
  796.     if Filesize==179109:
  797.       Scen.seek(160654+68*c,0)
  798.     if Filesize==169822:
  799.       Scen.seek(152711+68*c,0)
  800.     if Filesize==167559:
  801.       Scen.seek(150260+72*c,0)
  802.     if Filesize==167371:
  803.       Scen.seek(150260+68*c,0)
  804.     if 1<f<4:
  805.       Scen.write(bytes([8]))
  806.     if 3<f<6:
  807.       Scen.write(bytes([7]))
  808.     if 5<f<8:
  809.       Scen.write(bytes([6]))
  810.     if 7<f<12:
  811.       Scen.write(bytes([5]))
  812.     if 11<f<14:
  813.       Scen.write(bytes([4]))
  814.     if 13<f<18:
  815.       Scen.write(bytes([3]))
  816.     if 17<f<20:
  817.       Scen.write(bytes([2]))
  818.     if 19<f<24:
  819.       Scen.write(bytes([1]))
  820. #
  821. # RESEARCHED TECHNIQUES
  822. #
  823.     if res.get():
  824.       if Filesize==179109:
  825.         Scen.seek(160667+68*c,0)
  826.       if Filesize==169822:
  827.         Scen.seek(152724+68*c,0)
  828.       if Filesize==167559:
  829.         Scen.seek(150273+72*c,0)
  830.       if Filesize==167371:
  831.         Scen.seek(150273+68*c,0)
  832.       n = 4
  833.       while n:
  834.         if res.get()==1:
  835.           f = choice([0,1,3])*16+choice([0,1,3])
  836.         if res.get()==2:
  837.           f = choice([3,7])*16+choice([3,7])
  838.         if res.get()==3:
  839.           f = choice([7,15])*16+choice([7,15])
  840.         if res.get()==4:
  841.           f = choice([0,1,3,7,15])*16+choice([0,1,3,7,15])
  842.         Scen.write(bytes([f]))
  843.         n-=1
  844. #
  845. # RELATIONSHIPS BETWEEN FORCES
  846. #
  847.     for n in forces:
  848.       if n == c:
  849.         if Filesize==179109:
  850.           Scen.seek(160607+n+n*68,0)
  851.         if Filesize==169822:
  852.           Scen.seek(152664+n+n*68,0)
  853.         if Filesize==167559:
  854.           Scen.seek(150213+n+n*72,0)
  855.         if Filesize==167371:
  856.           Scen.seek(150213+n+n*68,0)
  857.         Scen.write(bytes([50]))
  858.       else:
  859.         q = [10*randrange(0,10)]
  860.         if Filesize==179109:
  861.           Scen.seek(160607+n+c*68)
  862.         if Filesize==169822:
  863.           Scen.seek(152664+n+c*68,0)
  864.         if Filesize==167559:
  865.           Scen.seek(150213+n+c*72,0)
  866.         if Filesize==167371:
  867.           Scen.seek(150213+n+c*68,0)
  868.         Scen.write(bytes(q))
  869.         if Filesize==179109:
  870.           Scen.seek(160607+c+n*68)
  871.         if Filesize==169822:
  872.           Scen.seek(152664+c+n*68,0)
  873.         if Filesize==167559:
  874.           Scen.seek(150213+c+n*72,0)
  875.         if Filesize==167371:
  876.           Scen.seek(150213+c+n*68,0)
  877.         Scen.write(bytes(q))
  878. #
  879. # GATES AND PORTS ASSIGNMENT
  880. #
  881.     for n in e:
  882.       f = gates[n]
  883.       if len(f):
  884.         for t in f:
  885.           if Filesize==179109:
  886.             Scen.seek(167577+t*64, 0)
  887.           if Filesize==169822:
  888.             Scen.seek(159634+t*64, 0)
  889.           if Filesize==167559:
  890.             Scen.seek(157371+t*64, 0)
  891.           if Filesize==167371:
  892.             Scen.seek(157183+t*64, 0)
  893.           Scen.write(bytes([b]))
  894.           r = 100*randrange(5,15)
  895.           Scen.write(bytes([r%256]))
  896.           Scen.write(bytes([r//256]))
  897.           Scen.write(bytes(2))
  898.           r = 100*randrange(5,10)
  899.           Scen.write(bytes([r%256]))
  900.           Scen.write(bytes([r//256]))
  901.           Scen.write(bytes(2))
  902.           r = 1000*randrange(5,10)
  903.           Scen.write(bytes([r%256]))
  904.           Scen.write(bytes([r//256]))
  905.           r = randrange(70,95)
  906.           if Filesize==179109:
  907.             Scen.seek(167638+t*64, 0)
  908.           if Filesize==169822:
  909.             Scen.seek(159695+t*64, 0)
  910.           if Filesize==167559:
  911.             Scen.seek(157432+t*64, 0)
  912.           if Filesize==167371:
  913.             Scen.seek(157244+t*64, 0)
  914.           Scen.write(bytes([r]))
  915. #
  916. #NEXT FORCE
  917. #
  918.     b+=1
  919. #
  920. # END OF FORCE CREATION LOOP
  921. #
  922. #
  923. # ADD ALLIANCES WHEN ALL FORCES ARE CREATED
  924. #
  925.   ally = []
  926.   if AllyVar.get()==1 and len(forces)>2:
  927.     n = randrange(1,len(forces))
  928.     print("There is a total of " + str(len(forces)) + " forces in this Scenario.")
  929.     while n>0:
  930.       roll=1
  931.       while roll:
  932.         f1 = randrange(0,len(forces))
  933.         c1 = forces[f1]
  934.         f2 = randrange(0,len(forces))
  935.         while f2==f1:
  936.           f2 = randrange(0,len(forces))
  937.         c2 = forces[f2]
  938.         allynum = pow(2,c1)+pow(2,c2)
  939.         if allynum in ally:
  940.           roll=1
  941.         if allynum not in ally:
  942.           ally.append(allynum)
  943.           roll=0
  944. #
  945. # ALLY SELECTED FORCE 1 TO FORCE 2
  946. #
  947.       if Filesize==179109:
  948.         Scen.seek(160659+c1*68,0)
  949.       if Filesize==169822:
  950.         Scen.seek(152716+c1*68,0)
  951.       if Filesize==167559:
  952.         Scen.seek(150265+c1*72,0)
  953.       if Filesize==167371:
  954.         Scen.seek(150265+c1*68,0)
  955.       k1 = ord(Scen.read(1))
  956.       k2 = ord(Scen.read(1))
  957.       k3 = ord(Scen.read(1))
  958.       k4 = ord(Scen.read(1))
  959.       k5 = ord(Scen.read(1))
  960.       k6 = ord(Scen.read(1))
  961.       k = 1099511627776*k6 + 4294967296*k5 + 16777216*k4 + 65536*k3 + 256*k2 + k1 + pow(2,c2)
  962.       if Filesize==179109:
  963.         Scen.seek(160659+c1*68,0)
  964.       if Filesize==169822:
  965.         Scen.seek(152716+c1*68,0)
  966.       if Filesize==167559:
  967.         Scen.seek(150265+c1*72,0)
  968.       if Filesize==167371:
  969.         Scen.seek(150265+c1*68,0)
  970.       if k<256:
  971.         dt = [k, 0, 0, 0, 0, 0]
  972.       if 255<k<65536:
  973.         dt = [k%256, k//256, 0, 0, 0, 0]
  974.       if 65535<k<16777216:
  975.         dt = [(k-65536)%256, k%65536//256, k//65536, 0, 0, 0]
  976.       if 16777215<k<4294967296:
  977.         dt = [k%16777216%65536%256, k%16777216%65536//256, k%16777216//65536, k//16777216, 0, 0]
  978.       if 4294967295<k<1099511627776:
  979.         dt = [k%4294967296%16777216%65536%256, k%4294967296%16777216%65536//256, k%4294967296%16777216//65536, k%4294967296//16777216, k//4294967296, 0]
  980.       if k>1099511627775:
  981.         dt = [k%4294967296%16777216%65536%256, k%4294967296%16777216%65536//256, k%4294967296%16777216//65536, k%4294967296//16777216, k//4294967296%256, k//4294967296//256]
  982.       Scen.write(bytes(dt))
  983. #
  984. # ALLY FORCE 2 TO FORCE 1
  985. #
  986.       if Filesize==179109:
  987.         Scen.seek(160659+c2*68,0)
  988.       if Filesize==169822:
  989.         Scen.seek(152716+c2*68,0)
  990.       if Filesize==167559:
  991.         Scen.seek(150265+c2*72,0)
  992.       if Filesize==167371:
  993.         Scen.seek(150265+c2*68,0)
  994.       k1 = ord(Scen.read(1))
  995.       k2 = ord(Scen.read(1))
  996.       k3 = ord(Scen.read(1))
  997.       k4 = ord(Scen.read(1))
  998.       k5 = ord(Scen.read(1))
  999.       k6 = ord(Scen.read(1))
  1000.       k = 1099511627776*k6 + 4294967296*k5 + 16777216*k4 + 65536*k3 + 256*k2 + k1 + pow(2,c1)
  1001.       if Filesize==179109:
  1002.         Scen.seek(160659+c2*68,0)
  1003.       if Filesize==169822:
  1004.         Scen.seek(152716+c2*68,0)
  1005.       if Filesize==167559:
  1006.         Scen.seek(150265+c2*72,0)
  1007.       if Filesize==167371:
  1008.         Scen.seek(150265+c2*68,0)
  1009.       if k<256:
  1010.         dt = [k, 0, 0, 0, 0, 0]
  1011.       if 255<k<65536:
  1012.         dt = [k%256, k//256, 0, 0, 0, 0]
  1013.       if 65535<k<16777216:
  1014.         dt = [(k-65536)%256, k%65536//256, k//65536, 0, 0, 0]
  1015.       if 16777215<k<4294967296:
  1016.         dt = [k%16777216%65536%256, k%16777216%65536//256, k%16777216//65536, k//16777216, 0, 0]
  1017.       if 4294967295<k<1099511627776:
  1018.         dt = [k%4294967296%16777216%65536%256, k%4294967296%16777216%65536//256, k%4294967296%16777216//65536, k%4294967296//16777216, k//4294967296, 0]
  1019.       if k>1099511627775:
  1020.         dt = [k%4294967296%16777216%65536%256, k%4294967296%16777216%65536//256, k%4294967296%16777216//65536, k%4294967296//16777216, k//4294967296%256, k//4294967296//256]
  1021.       Scen.write(bytes(dt))
  1022.       n-=1
  1023. #
  1024. # ITEM RANDOMIZER
  1025. #
  1026.   if ItemVar.get()==1:
  1027.     k = 0
  1028.     while k<43:
  1029.       n = choice([0,0,0,1])
  1030.       if n==1 and len(leaderslist)==True:
  1031.         owner = choice(leaderslist)
  1032.         cty = 255
  1033.       if n==0:
  1034.         owner = 65535
  1035.         cty = randrange(0,42)
  1036.       if Filesize==179109:
  1037.         Scen.seek(157233+34*k,0)
  1038.       if Filesize==169822:
  1039.         Scen.seek(147013+57*k, 0)
  1040.       if Filesize==167559 or Filesize==167371:
  1041.         Scen.seek(144562+57*k, 0)
  1042.       Scen.write(bytes([owner%256, owner//256, cty, n]))
  1043.       k+=1
  1044. #
  1045. #END OF RANDOMIZER
  1046. #
  1047.   print("There is a total of " + str(len(offi)) + " free officers available the first year.")
  1048.   print(str(len(ally)) + " alliances have been created.")
  1049.   print(str(TotalNewOff) + " fictional officers have been created.")
  1050.   Scen.close()
  1051.   messagebox.showinfo("Info", "Your Scenario has been randomized")
  1052. #
  1053. # WINDOWS GUI CREATION
  1054. #
  1055. window = Tk()
  1056. window.wm_title("RandOTK11 V1.06")
  1057. rdoff = IntVar()
  1058. HistVar = IntVar()
  1059. LifeVar = IntVar()
  1060. LikeVar = IntVar()
  1061. CityVar = IntVar()
  1062. NewOVar = IntVar()
  1063. TiesVar = IntVar()
  1064. RevHarVar = IntVar()
  1065. CitySpeVar = IntVar()
  1066. CityVar.set(1)
  1067. AllyVar = IntVar()
  1068. AllyVar.set(1)
  1069. ItemVar = IntVar()
  1070. ItemVar.set(0)
  1071. IA = IntVar()
  1072. IA.set(1)
  1073. res = IntVar()
  1074. res.set(0)
  1075. equi = IntVar()
  1076. equi.set(1)
  1077. #
  1078. # GUI : OPEN RANDOMIZE AND EXIT BUTTONS
  1079. #
  1080. openbtn = Button(window, text = "Open File", width = 10, command = openSCEN)
  1081. openbtn.grid(row = 10, column = 1)
  1082. randbtn = Button(window, text = "Randomize", width = 10, state = DISABLED, command = Randomize)
  1083. randbtn.grid(row = 10, column = 2)
  1084. exitbtn = Button(window, text = "Exit", width = 10, command = exitrandotk)
  1085. exitbtn.grid(row = 10, column = 5)
  1086. helpbtn = Button(window, text = "Info", width = 10, command = info)
  1087. helpbtn.grid(row = 10, column = 4)
  1088. #
  1089. # GUI : STARTING DATE - FORCE NUMBER  AND FREE CITIES ENTRIES
  1090. #
  1091. SdateLabel = Label(window, text = "Starting Year: ")
  1092. SdateLabel.grid(row = 1, column = 1)
  1093. SdateEntry = Entry(window, width = 8, justify = CENTER)
  1094. SdateEntry.grid(row = 1, column = 2, sticky = W)
  1095. FnumLabel = Label(window, text = "Number of Forces: ")
  1096. FnumLabel.grid(row = 2, column = 1)
  1097. FnumEntry = Entry(window, width = 8, justify = CENTER)
  1098. FnumEntry.grid(row = 2, column = 2, sticky = W)
  1099. FcityLabel = Label(window, text = "Minimum free cities: ")
  1100. FcityLabel.grid(row = 3, column = 1)
  1101. FcityEntry = Entry(window, width = 8, justify = CENTER)
  1102. FcityEntry.insert(0, "0")
  1103. FcityEntry.grid(row = 3, column = 2, sticky = W)
  1104. #
  1105. # GUI : CHECKBOXES
  1106. #
  1107. GlobalLabel = Label(window, text = "Global Setup:")
  1108. GlobalLabel.grid(row = 1, column = 3, sticky = E)
  1109. HistCkb = Checkbutton(window, text = "Historical Leaders", variable = HistVar)
  1110. HistCkb.grid(row = 2, column = 5, sticky = W)
  1111. CityCkb = Checkbutton(window, text = "Uniform city distribution", variable = CityVar)
  1112. CityCkb.grid(row = 1, column = 4, sticky = W)
  1113. AllyCkb = Checkbutton(window, text = "Add Alliances", variable = AllyVar)
  1114. AllyCkb.grid(row = 2, column = 4, sticky = W)
  1115. ItemCkb = Checkbutton(window, text = "Random Item distribution", variable = ItemVar)
  1116. ItemCkb.grid(row = 1, column = 5, sticky = W)
  1117. #
  1118. # GUI : LISTBOX FORCE BALANCE
  1119. #
  1120. BlncLabel = Label(window, text = "Balance Setup:")
  1121. BlncLabel.grid(row = 4, column = 3, sticky = W)
  1122. BlncRdb1 = Radiobutton(window, text = "Similar sized forces", variable = equi, value = 1)
  1123. BlncRdb1.grid(row = 5, column = 3, sticky = W)
  1124. BlncRdb2 = Radiobutton(window, text = "Random sized forces", variable = equi, value = 2)
  1125. BlncRdb2.grid(row = 6, column = 3, sticky = W)
  1126. BlncRdb3 = Radiobutton(window, text = "One city forces", variable = equi, value = 3)
  1127. BlncRdb3.grid(row = 7, column = 3, sticky = W)
  1128. BlncRdb4 = Radiobutton(window, text = "Random Setup", variable = equi, value = 4)
  1129. BlncRdb4.grid(row = 8, column = 3, sticky = W)
  1130. #
  1131. # GUI : LISTBOX TECHNIQUES
  1132. #
  1133. TchqLabel = Label(window, text = "Research Setup:")
  1134. TchqLabel.grid(row = 4, column = 1, sticky = W)
  1135. TchqRdb1 = Radiobutton(window, text = "No research", variable = res, value = 0)
  1136. TchqRdb1.grid(row = 5, column = 1, sticky = W)
  1137. TchqRdb2 = Radiobutton(window, text = "Low research", variable = res, value = 1)
  1138. TchqRdb2.grid(row = 6, column = 1, sticky = W)
  1139. TchqRdb3 = Radiobutton(window, text = "Medium research", variable = res, value = 2)
  1140. TchqRdb3.grid(row = 7, column = 1, sticky = W)
  1141. TchqRdb4 = Radiobutton(window, text = "High research", variable = res, value = 3)
  1142. TchqRdb4.grid(row = 8, column = 1, sticky = W)
  1143. TchqRdb5 = Radiobutton(window, text = "Random research", variable = res, value = 4)
  1144. TchqRdb5.grid(row = 9, column = 1, sticky = W)
  1145. #
  1146. # GUI : RADIOBUTTON IA SETUP
  1147. #
  1148. IALabel = Label(window, text = "IA Setup:")
  1149. IALabel.grid(row = 4, column = 2, sticky = W)
  1150. IARdb1 = Radiobutton(window, text = "Aggressive IA", variable = IA, value = 1)
  1151. IARdb1.grid(row = 5, column = 2, sticky = W)
  1152. IARdb2 = Radiobutton(window, text = "Moderate IA", variable = IA, value = 2)
  1153. IARdb2.grid(row = 6, column = 2, sticky = W)
  1154. IARdb3 = Radiobutton(window, text = "Random IA", variable = IA, value = 3)
  1155. IARdb3.grid(row = 7, column = 2, sticky = W)
  1156. #
  1157. # OFFICER RANDOMIZATION SETUP
  1158. #
  1159. OfrdzLabel = Label(window, text = "Officers Setup:")
  1160. OfrdzLabel.grid(row = 4, column = 4, sticky = W)
  1161. OffiCkb = Checkbutton(window, text = "Random Stats-APT-Skills", variable = rdoff)
  1162. OffiCkb.grid(row = 5, column = 4, sticky = W)
  1163. LifeCkb = Checkbutton(window, text = "Random Lifespans", variable = LifeVar)
  1164. LifeCkb.grid(row = 6, column = 4, sticky = W)
  1165. RelaCkb = Checkbutton(window, text = "Random Liked/Disliked", variable = LikeVar)
  1166. RelaCkb.grid(row = 7, column = 4, sticky = W)
  1167. NewOCkb = Checkbutton(window, text = "Create random officers", variable = NewOVar, command = ForceTies)
  1168. NewOCkb.grid(row = 8, column = 4, sticky = W)
  1169. TiesCkb = Checkbutton(window, text = "Cut family/sworn ties", variable = TiesVar, command = ForceNoNewO)
  1170. TiesCkb.grid(row = 9, column = 4, sticky = W)
  1171. #
  1172. # CITIES RANDOMIZATION SETUP
  1173. #
  1174. CityRdzLabel = Label(window, text = "Cities Setup:")
  1175. CityRdzLabel.grid(row = 4, column = 5, sticky = W)
  1176. CitySpeCkb = Checkbutton(window, text = "Random Specialty", variable = CitySpeVar)
  1177. CitySpeCkb.grid(row = 5, column = 5, sticky = W)
  1178. RevHarCkb = Checkbutton(window, text = "Random Revenue/Harvest", variable = RevHarVar)
  1179. RevHarCkb.grid(row = 6, column = 5, sticky = W)
  1180. window.mainloop()
  1181. #
  1182. #END OF CODE
  1183. #
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement