---------------------------------------------------------------------------- -- Conquest -- My first attempt at a semi-abstract wargame -- Mark K. Akita 2/13/01 -- changes by Jordan Bell 6/28/06 -- Added 6th player -- Increased number of cities from set 29 to random number upto 180 -- Improved variable names and documentation to make code more understandable -- Increased starting cities per player (previously only 2) -- Increased playing area size and text font size ---------------------------------------------------------------------------- without type_check without warning include win32lib.ew integer numplay,gd,curplay,curcty,desco,di, Cities sequence map,cntryloc,am,xmin,xmax,ymin,ymax sequence owner,armies,players,orders,ptype sequence Msg1 -- Cities = Number of Cities -- numplay = number of players -- map = the map sequence -- players = player sequence -- cntryloc = country locations -- xmin,xmax,ymin,ymax = country bounds for redrawing -- owner = owner sequence -- armies = army sequence -- orders = current build/move orders by country -- ptype = player type (human or 'puter) -- curplay = current player -- curcty = current country selected -- desco = destination country -- di = destination index -- am = adjacent country matrix -- Define the window and menus constant MyWindow=create(Window,"Conquest",0,Default,Default,800,580,0) constant FileMenu=create(Menu,"&File",MyWindow,0,0,0,0,0) constant New=create(MenuItem,"&New Game", FileMenu,0,0,0,0,0) constant Exit=create(MenuItem,"E&xit", FileMenu,0,0,0,0,0) constant HelpMenu=create(Menu,"&Help",MyWindow,0,0,0,0,0) constant About=create(MenuItem,"&About",HelpMenu,0,0,0,0,0) -- Define the Buffer constant Buffer=create(Pixmap,"",0,0,0,768,512,0) constant Buffer2=create(Pixmap,"",0,0,0,768,16,0) constant Buffer3=create(Pixmap,"",0,0,0,768,512,0) -- Define the Setup Controls constant Group1=create(Group,"Player 1",MyWindow,45,50,300,40,WS_VISIBLE) constant Button1A=create(Radio,"Human",Group1,5,18,85,17,WS_VISIBLE) constant Button1B=create(Radio,"Computer",Group1,100,18,85,17,WS_VISIBLE) constant Group2=create(Group,"Player 2",MyWindow,45,100,300,40,WS_VISIBLE) constant Button2A=create(Radio,"Human",Group2,5,18,85,17,WS_VISIBLE) constant Button2B=create(Radio,"Computer",Group2,100,18,85,17,WS_VISIBLE) constant Group3=create(Group,"Player 3",MyWindow,45,150,300,40,WS_VISIBLE) constant Button3A=create(Radio,"Human",Group3,5,18,85,17,WS_VISIBLE) constant Button3B=create(Radio,"Computer",Group3,100,18,85,17,WS_VISIBLE) constant Button3C=create(Radio,"Off",Group3,195,18,85,17,WS_VISIBLE) constant Group4=create(Group,"Player 4",MyWindow,45,200,300,40,WS_VISIBLE) constant Button4A=create(Radio,"Human",Group4,5,18,85,17,WS_VISIBLE) constant Button4B=create(Radio,"Computer",Group4,100,18,85,17,WS_VISIBLE) constant Button4C=create(Radio,"Off",Group4,195,18,85,17,WS_VISIBLE) constant Group5=create(Group,"Player 5",MyWindow,45,250,300,40,WS_VISIBLE) constant Button5A=create(Radio,"Human",Group5,5,18,85,17,WS_VISIBLE) constant Button5B=create(Radio,"Computer",Group5,100,18,85,17,WS_VISIBLE) constant Button5C=create(Radio,"Off",Group5,195,18,85,17,WS_VISIBLE) constant Group6=create(Group,"Player 6",MyWindow,45,300,300,40,WS_VISIBLE) constant Button6A=create(Radio,"Human",Group6,5,18,85,17,WS_VISIBLE) constant Button6B=create(Radio,"Computer",Group6,100,18,85,17,WS_VISIBLE) constant Button6C=create(Radio,"Off",Group6,195,18,85,17,WS_VISIBLE) constant Button7=create(PushButton,"OK",MyWindow,205,350,55,24,WS_VISIBLE) constant Button8=create(PushButton,"Cancel",MyWindow,280,350,55,24,WS_VISIBLE) constant Button9=create(PushButton,"<",MyWindow,150,514,24,24,WS_VISIBLE) constant Button10=create(PushButton,">",MyWindow,180,514,24,24,WS_VISIBLE) constant Group11=create(Group,"",MyWindow,240,510,110,30,WS_VISIBLE) constant Button11A=create(Radio,"Build",Group11,5,10,45,17,WS_VISIBLE) constant Button11B=create(Radio,"Move",Group11,55,10,45,17,WS_VISIBLE) constant Button12=create(PushButton,"<",MyWindow,370,514,24,24,WS_VISIBLE) constant Button13=create(PushButton,">",MyWindow,400,514,24,24,WS_VISIBLE) constant Scroll1=create(HScroll,"Armies",MyWindow,445,525,110,16,WS_VISIBLE) constant ScrollH1=create(CText,"Armies: 0",MyWindow,445,510,110,15,0) constant Button14=create(PushButton,"End Turn",MyWindow,572,514,55,24,WS_VISIBLE) -- Check radio buttions setCheck(Button1A,True) setCheck(Button2B,True) setCheck(Button3C,True) setCheck(Button4C,True) setCheck(Button5C,True) setCheck(Button6C,True) setCheck(Button11A,True) -- Make some controls inivisble until we need them setVisible(Group1,False) setEnable(Group1,False) setVisible(Group2,False) setEnable(Group2,False) setVisible(Group3,False) setEnable(Group3,False) setVisible(Group4,False) setEnable(Group4,False) setVisible(Group5,False) setEnable(Group5,False) setVisible(Group6,False) setEnable(Group6,False) setVisible(Button7,False) setEnable(Button7,False) setVisible(Button8,False) setEnable(Button8,False) setVisible(Button9,False) setEnable(Button9,False) setVisible(Button10,False) setEnable(Button10,False) setVisible(Group11,False) setEnable(Group11,False) setVisible(Button12,False) setEnable(Button12,False) setVisible(Button13,False) setEnable(Button13,False) setVisible(Button14,False) setEnable(Button14,False) setVisible(Scroll1,False) setEnable(Scroll1,False) setVisible(ScrollH1,False) gd=0 curplay=0 ---------------------------------------------------------------------------- setWindowBackColor(MyWindow,BrightWhite) ---------------------------------------------------------------------------- function str_val(integer i1) sequence s1 integer i2,i3 i3=i1 i1=abs(i1) s1="" if i1=0 then s1="0" else while i1>0 do i2=remainder(i1,10) s1={i2+'0'}&s1 i1=floor(i1/10) end while end if if i3<0 then s1="-"&s1 end if return s1 end function ---------------------------------------------------------------------------- procedure Redraw(integer x1,integer y1,integer x2,integer y2) integer tx object o1 setFont(MyWindow,"Arial",12,Normal) o1=getTextExtent(MyWindow,Msg1) tx=o1[1] tx=floor((x2-x1)/2-tx/2) if tx<0 then tx=0 end if setTextColor(MyWindow,Black) if curplay>0 then if players[curplay]=1 then setTextColor(MyWindow,#BB0000) end if if players[curplay]=2 then setTextColor(MyWindow,#0000BB) end if if players[curplay]=3 then setTextColor(MyWindow,#00BB00) end if if players[curplay]=4 then setTextColor(MyWindow,#00BBBB) end if if players[curplay]=5 then setTextColor(MyWindow,#BB00BB) end if if players[curplay]=6 then setTextColor(MyWindow,#BBBB00) end if end if setPosition(MyWindow,5,400) wPuts(MyWindow,Msg1) setDefaultFont(MyWindow) setTextColor(MyWindow,Black) if gd=0 then copyBlt(MyWindow,2,2,Buffer) end if if gd=1 then setPenColor(MyWindow,#BB0000) drawRectangle(MyWindow,True,45,50,345,90) setPenColor(MyWindow,#0000BB) drawRectangle(MyWindow,True,45,100,345,140) setPenColor(MyWindow,#00BB00) drawRectangle(MyWindow,True,45,150,345,190) setPenColor(MyWindow,#00BBBB) drawRectangle(MyWindow,True,45,200,345,240) setPenColor(MyWindow,#BBBB00) drawRectangle(MyWindow,True,45,250,345,290) setPenColor(MyWindow,#BB00BB) drawRectangle(MyWindow,True,45,300,345,340) end if if gd=2 then copyBlt(MyWindow,2,300,Buffer2) end if end procedure ---------------------------------------------------------------------------- procedure onMenu_Exit() closeWindow(MyWindow) end procedure ---------------------------------------------------------------------------- procedure drawMap() integer c,curcty,ss ss=0 setPenColor(Buffer2,BrightWhite) drawRectangle(Buffer2,True,0,0,768,32) for x=1 to 769 do setPenColor(Buffer2,remainder(x,256)*#100) drawLine(Buffer2,x,0,x,16) ss += 1 if ss>7 then ss=0 repaintRect(MyWindow,0,300,600,316) end if for y=1 to 513 do c=map[x][y][1] if map[x][y][3]=1 then c=floor(c/2) end if if c>=0 then curcty=remainder(map[x][y][2],6) if map[x][y][2]>0 then curcty=owner[map[x][y][2]] end if if curcty=0 then curcty=#10101 elsif curcty=1 then curcty=#010000 elsif curcty=2 then curcty=#000001 elsif curcty=3 then curcty=#000100 elsif curcty=4 then curcty=#000101 elsif curcty=5 then curcty=#010100 else curcty=#010001 end if c=(floor(c/2)+127)*curcty else c *= -1 c=#10100*(256-c) end if setPixel(Buffer,x-1,y-1,c) end for end for setFont(Buffer,"Arial",10,Normal) setTextColor(Buffer,Black) setPenColor(Buffer,Black) for i=1 to Cities do setPosition(Buffer,cntryloc[i][1]-8,cntryloc[i][2]+6) wPuts(Buffer,str_val(armies[i])) drawEllipse(Buffer,0,cntryloc[i][1]-5,cntryloc[i][2]-5,cntryloc[i][1]+5,cntryloc[i][2]+5) drawEllipse(Buffer,1,cntryloc[i][1]-2,cntryloc[i][2]-2,cntryloc[i][1]+2,cntryloc[i][2]+2) end for end procedure ---------------------------------------------------------------------------- procedure MakeMap() -- Runs once to create random map -- City sort added after map creation to make game easier to play integer bb,tx,ty,done,ss atom d,md,ml sequence tm tm=repeat(repeat(0,Cities),Cities) am=repeat({},Cities) map=repeat(repeat({0,0,0},513),769) ss=0 for x=1 to 769 by 64 do for y=1 to 513 by 64 do map[x][y][1]=rand(256)-128 end for end for setPenColor(Buffer2,BrightWhite) drawRectangle(Buffer2,True,0,0,768,32) bb=64 -- Fractal land creation, bigger number = bigger land masses for i=1 to 6 do -- 2^7 = 128, so final iteration bb = 1 bb=bb/2 tx=0 for x=1 to 769 by bb do ty=0 setPenColor(Buffer2,remainder(x,256)) drawLine(Buffer2,x,00,x,16) ss += 1 if ss>7 then ss=0 repaintRect(MyWindow,0,300,600,316) end if for y=1 to 513 by bb do if tx and not ty then map[x][y][1]=(map[x-bb][y][1]+map[x+bb][y][1])/2+rand(bb*2)-bb end if if ty and not tx then map[x][y][1]=(map[x][y-bb][1]+map[x][y+bb][1])/2+rand(bb*2)-bb end if if tx and ty then if remainder(i,2) then map[x][y][1]=(map[x-bb][y-bb][1]+map[x+bb][y+bb][1])/2+rand(bb*2)-bb else map[x][y][1]=(map[x-bb][y+bb][1]+map[x+bb][y-bb][1])/2+rand(bb*2)-bb end if end if ty=1-ty -- toggles ty between 0 and 1 map[x][y][1]=floor(map[x][y][1]+.5) end for tx=1-tx -- sets tx to 0 or 1, whichever ty isnt end for end for cntryloc=repeat({0,0},Cities) -- Initialize the variable cntryloc[1][1]=rand(750)+8 -- Start generating city locations cntryloc[1][2]=rand(480)+8 for i=2 to Cities do done=False while not done do cntryloc[i][1]=rand(750)+8 cntryloc[i][2]=rand(480)+8 if map[cntryloc[i][1]][cntryloc[i][2]][1]>=0 then done=True for j=1 to (i-1) do d=sqrt(power((cntryloc[i][1]-cntryloc[j][1]),2)+power((cntryloc[i][2]-cntryloc[j][2]),2)) if d<24 then done=False end if end for end if end while end for for i=1 to (Cities-1) do -- sort cities by location for j= (Cities-1) to i by -1 do if ((cntryloc[j][1] > cntryloc[j+1][1]) or ((cntryloc[j][1] = cntryloc[j+1][1]) and (cntryloc[j][2] > cntryloc[j+1][2]))) then tx = cntryloc[j][1] ty = cntryloc[j][2] cntryloc[j][1] = cntryloc[j+1][1] cntryloc[j][2] = cntryloc[j+1][2] cntryloc[j+1][1] = tx cntryloc[j+1][2] = ty end if end for end for xmin=repeat(768,Cities) xmax=repeat(1,Cities) ymin=repeat(512,Cities) ymax=repeat(1,Cities) setPenColor(Buffer2,BrightWhite) drawRectangle(Buffer2,True,0,0,768,32) for x=1 to 768 do setPenColor(Buffer2,remainder(x,256)*#10000) drawLine(Buffer2,x,0,x,16) ss += 1 if ss>7 then ss=0 repaintRect(MyWindow,0,300,600,316) end if for y=1 to 512 do md=9999 ml=0 for i=1 to Cities do d=sqrt(power((cntryloc[i][1]-x),2)+power((cntryloc[i][2]-y),2)) if d1 and (map[x-1][y][2]!=ml) then map[x][y][3]=1 tm[ml][map[x-1][y][2]]=1 tm[map[x-1][y][2]][ml]=1 end if if y>1 and (map[x][y-1][2]!=ml) then map[x][y][3]=1 tm[ml][map[x][y-1][2]]=1 tm[map[x][y-1][2]][ml]=1 end if if xxmax[ml] then xmax[ml]=x end if if yymin[ml] then ymax[ml]=y end if end for end for for x=1 to Cities do for y=1 to Cities do if tm[x][y] then am[x]=am[x]&y end if end for end for end procedure ---------------------------------------------------------------------------- procedure Hilight1() setPenColor(Buffer,BrightWhite) drawEllipse(Buffer,0,cntryloc[curcty][1]-5,cntryloc[curcty][2]-5,cntryloc[curcty][1]+5,cntryloc[curcty][2]+5) drawEllipse(Buffer,1,cntryloc[curcty][1]-2,cntryloc[curcty][2]-2,cntryloc[curcty][1]+2,cntryloc[curcty][2]+2) setTextColor(Buffer,BrightWhite) setPosition(Buffer,cntryloc[curcty][1]-8,cntryloc[curcty][2]+6) wPuts(Buffer,str_val(armies[curcty])) drawEllipse(Buffer,0,cntryloc[curcty][1]-25,cntryloc[curcty][2]-25,cntryloc[curcty][1]+25,cntryloc[curcty][2]+25) end procedure ---------------------------------------------------------------------------- procedure Hilight2() setPenColor(Buffer,Black) drawLine(Buffer,cntryloc[curcty][1],cntryloc[curcty][2],cntryloc[desco][1],cntryloc[desco][2]) setPenColor(Buffer,BrightWhite) drawRectangle(Buffer,0,cntryloc[desco][1]-20,cntryloc[desco][2]-20,cntryloc[desco][1]+20,cntryloc[desco][2]+20) drawEllipse(Buffer,0,cntryloc[desco][1]-5,cntryloc[desco][2]-5,cntryloc[desco][1]+5,cntryloc[desco][2]+5) drawEllipse(Buffer,1,cntryloc[desco][1]-2,cntryloc[desco][2]-2,cntryloc[desco][1]+2,cntryloc[desco][2]+2) setTextColor(Buffer,BrightWhite) setPosition(Buffer,cntryloc[desco][1]-8,cntryloc[desco][2]+6) wPuts(Buffer,str_val(armies[desco])) end procedure ---------------------------------------------------------------------------- procedure do_orders() integer at,df,ar,dr,oo,fi,done for i=1 to Cities do if sequence(orders[i]) then -- Check for any moves at=orders[i][1] if at<1 then at=1 end if armies[i] -= at df=armies[orders[i][2]] if df=0 then owner[orders[i][2]]=players[curplay] armies[orders[i][2]]=at else if owner[i]=owner[orders[i][2]] then armies[orders[i][2]]=at+df if armies[orders[i][2]]>99 then -- city pop limit 99 armies[orders[i][2]]=99 end if else done=False while not done do -- Combat calculations ar=rand(at+1) dr=rand(df+1) if ar>dr then df -= 1 else at -= 1 end if if at=0 then done=True armies[orders[i][2]]=df end if if df=0 then done=True armies[orders[i][2]]=at oo=owner[orders[i][2]] owner[orders[i][2]]=players[curplay] if not find(oo,owner) then fi=find(oo,players) if fi=1 then players=players[2..numplay] elsif fi=numplay then players=players[1..(numplay-1)] else players=players[1..(fi-1)]&players[(fi+1)..numplay] end if numplay=numplay-1 curplay=find(owner[orders[i][2]],players) if numplay<2 then setVisible(Button9,False) setEnable(Button9,False) setVisible(Button10,False) setEnable(Button10,False) setVisible(Group11,False) setEnable(Group11,False) setVisible(Button12,False) setEnable(Button12,False) setVisible(Button13,False) setEnable(Button13,False) setVisible(Button14,False) setEnable(Button14,False) setVisible(Scroll1,False) setEnable(Scroll1,False) setVisible(ScrollH1,False) Msg1="Player "&str_val(players[curplay])&" wins!" gd=2 drawMap() copyBlt(Buffer3,0,0,Buffer) gd=0 ptype=repeat(0,5) repaintWindow(MyWindow) exit end if end if end if end while end if end if else if orders[i]<0 then armies[i] += 1 if armies[i]>99 then -- city pop limit changed to 99 armies[i]=99 end if end if end if end for end procedure ---------------------------------------------------------------------------- procedure comp_turn() integer mina,maxa,mine,maxe orders=repeat(0,Cities) for i=1 to Cities do if owner[i]=players[curplay] then orders[i]=-1 if armies[i]>1 then mine=1 maxe=1 mina=100 maxa=0 for j=1 to length(am[i]) do if owner[am[i][j]]!=players[curplay] then if armies[am[i][j]]maxa then maxe=am[i][j] maxa=armies[maxe] end if end if end for if (armies[i]+rand(8)-4)>maxa then orders[i]={rand(armies[i]-1),mine} end if end if end if end for do_orders() if numplay=1 then return end if gd=0 curplay += 1 if curplay>numplay then curplay=1 end if end procedure ---------------------------------------------------------------------------- procedure onMenu_New() gd=1 curplay=0 Msg1="" setVisible(Group1,True) setEnable(Group1,True) setVisible(Group2,True) setEnable(Group2,True) setVisible(Group3,True) setEnable(Group3,True) setVisible(Group4,True) setEnable(Group4,True) setVisible(Group5,True) setEnable(Group5,True) setVisible(Group6,True) setEnable(Group6,True) setVisible(Button7,True) setEnable(Button7,True) setVisible(Button8,True) setEnable(Button8,True) setVisible(Button9,False) setEnable(Button9,False) setVisible(Button10,False) setEnable(Button10,False) setVisible(Group11,False) setEnable(Group11,False) setVisible(Button12,False) setEnable(Button12,False) setVisible(Button13,False) setEnable(Button13,False) setVisible(Button14,False) setEnable(Button14,False) setVisible(Scroll1,False) setEnable(Scroll1,False) setVisible(ScrollH1,False) repaintWindow(MyWindow) end procedure ---------------------------------------------------------------------------- procedure onButton7() -- OK Button for New Game integer r gd=2 setVisible(Group1,False) setEnable(Group1,False) setVisible(Group2,False) setEnable(Group2,False) setVisible(Group3,False) setEnable(Group3,False) setVisible(Group4,False) setEnable(Group4,False) setVisible(Group5,False) setEnable(Group5,False) setVisible(Group6,False) setEnable(Group6,False) setVisible(Button7,False) setEnable(Button7,False) setVisible(Button8,False) setEnable(Button8,False) players={1,2} if isChecked(Button3A) or isChecked(Button3B) then players &= {3} end if if isChecked(Button4A) or isChecked(Button4B) then players &= {4} end if if isChecked(Button5A) or isChecked(Button5B) then players &= {5} end if if isChecked(Button6A) or isChecked(Button6B) then players &= {6} end if numplay=length(players) Cities=numplay*numplay for i = 1 to numplay do Cities += rand(numplay*numplay) end for if Cities > 180 then Cities = 180 end if ptype=repeat(0,6) if isChecked(Button1B) then ptype[1] = 1 end if if isChecked(Button2B) then ptype[2] = 1 end if if isChecked(Button3B) then ptype[3] = 1 end if if isChecked(Button4B) then ptype[4] = 1 end if if isChecked(Button5B) then ptype[5] = 1 end if if isChecked(Button6B) then ptype[6] = 1 end if owner=repeat(0,Cities) armies=repeat(0,Cities) for j=1 to numplay do -- 1 city per player per player for i=1 to numplay do -- loop through each player to allocate cities r=rand(Cities) while owner[r]!=0 do r=rand(Cities) end while owner[r]=players[i] armies[r]=2 end for end for setPenColor(Buffer,BrightWhite) drawRectangle(Buffer,True,0,0,768,512) Msg1="Creating a map" repaintWindow(MyWindow) MakeMap() curplay=1 gd=0 setVisible(Button9,True) setEnable(Button9,True) setVisible(Button10,True) setEnable(Button10,True) setVisible(Group11,True) setEnable(Group11,True) setVisible(Button14,True) setEnable(Button14,True) copyBlt(Buffer3,0,0,Buffer) while ptype[players[curplay]] do comp_turn() end while gd=2 drawMap() gd=0 Msg1="Player "&str_val(players[curplay]) orders=repeat(0,Cities) for i=1 to Cities do if owner[i]=players[curplay] then orders[i]=-1 end if end for copyBlt(Buffer3,0,0,Buffer) curcty=find(players[curplay],owner) Hilight1() repaintWindow(MyWindow) end procedure ---------------------------------------------------------------------------- procedure onButton8() -- Cancel Button for New Game gd=0 curplay=0 Msg1="" setVisible(Group1,False) setEnable(Group1,False) setVisible(Group2,False) setEnable(Group2,False) setVisible(Group3,False) setEnable(Group3,False) setVisible(Group4,False) setEnable(Group4,False) setVisible(Group5,False) setEnable(Group5,False) setVisible(Group6,False) setEnable(Group6,False) setVisible(Button7,False) setEnable(Button7,False) setVisible(Button8,False) setEnable(Button8,False) setVisible(Button9,False) setEnable(Button9,False) setVisible(Button10,False) setEnable(Button10,False) setVisible(Group11,False) setEnable(Group11,False) setVisible(Button12,False) setEnable(Button12,False) setVisible(Button13,False) setEnable(Button13,False) setVisible(Button14,False) setEnable(Button14,False) setVisible(Scroll1,False) setEnable(Scroll1,False) setVisible(ScrollH1,False) repaintWindow(MyWindow) end procedure ---------------------------------------------------------------------------- procedure onButton9() -- Select Previous Territory curcty -=1 if curcty<1 then curcty=Cities end if while owner[curcty]!=players[curplay] do curcty -= 1 if curcty<1 then curcty=Cities end if end while copyBlt(Buffer,0,0,Buffer3) if sequence(orders[curcty]) then desco=orders[curcty][2] di=find(desco,am[curcty]) Hilight2() setVisible(Button12,True) setEnable(Button12,True) setVisible(Button13,True) setEnable(Button13,True) setVisible(Scroll1,True) setEnable(Scroll1,True) setVisible(ScrollH1,True) setCheck(Button11A,False) setCheck(Button11B,True) setScrollRange(Scroll1,1,armies[curcty]-1) setScrollPos(Scroll1,orders[curcty][1]) else setVisible(Button12,False) setEnable(Button12,False) setVisible(Button13,False) setEnable(Button13,False) setVisible(Scroll1,False) setEnable(Scroll1,False) setVisible(ScrollH1,False) setCheck(Button11B,False) setCheck(Button11A,True) end if Hilight1() repaintWindow(MyWindow) end procedure ---------------------------------------------------------------------------- procedure onButton10() -- Select Next territory curcty +=1 if curcty>Cities then curcty=1 end if while owner[curcty]!=players[curplay] do curcty += 1 if curcty>Cities then curcty=1 end if end while copyBlt(Buffer,0,0,Buffer3) if sequence(orders[curcty]) then desco=orders[curcty][2] di=find(desco,am[curcty]) Hilight2() setVisible(Button12,True) setEnable(Button12,True) setVisible(Button13,True) setEnable(Button13,True) setVisible(Scroll1,True) setEnable(Scroll1,True) setVisible(ScrollH1,True) setCheck(Button11A,False) setCheck(Button11B,True) setScrollRange(Scroll1,1,armies[curcty]-1) setScrollPos(Scroll1,orders[curcty][1]) else setVisible(Button12,False) setEnable(Button12,False) setVisible(Button13,False) setEnable(Button13,False) setVisible(Scroll1,False) setEnable(Scroll1,False) setVisible(ScrollH1,False) setCheck(Button11B,False) setCheck(Button11A,True) end if Hilight1() repaintWindow(MyWindow) end procedure ---------------------------------------------------------------------------- procedure onButton11A() -- Build Button setVisible(Button12,False) setEnable(Button12,False) setVisible(Button13,False) setEnable(Button13,False) setVisible(Scroll1,False) setEnable(Scroll1,False) setVisible(ScrollH1,False) orders[curcty]=-1 copyBlt(Buffer,0,0,Buffer3) Hilight1() repaintWindow(MyWindow) end procedure ---------------------------------------------------------------------------- procedure onButton11B() -- Move Button if armies[curcty]>1 then setVisible(Button12,True) setEnable(Button12,True) setVisible(Button13,True) setEnable(Button13,True) setVisible(Scroll1,True) setEnable(Scroll1,True) setVisible(ScrollH1,True) setScrollRange(Scroll1,1,armies[curcty]-1) setScrollPos(Scroll1,1) di=1 orders[curcty]={1,am[curcty][di]} desco=am[curcty][di] copyBlt(Buffer,0,0,Buffer3) Hilight2() Hilight1() repaintWindow(MyWindow) else setCheck(Button11A,True) setCheck(Button11B,False) end if end procedure ---------------------------------------------------------------------------- procedure onButton12() -- Select Previous Destination di -= 1 if di<1 then di=length(am[curcty]) end if orders[curcty]={0,am[curcty][di]} desco=am[curcty][di] copyBlt(Buffer,0,0,Buffer3) Hilight2() Hilight1() repaintWindow(MyWindow) end procedure ---------------------------------------------------------------------------- procedure onButton13() -- Select Next Destination Territory di += 1 if di>length(am[curcty]) then di=1 end if orders[curcty]={0,am[curcty][di]} desco=am[curcty][di] copyBlt(Buffer,0,0,Buffer3) Hilight2() Hilight1() repaintWindow(MyWindow) end procedure ---------------------------------------------------------------------------- procedure onButton14() -- End Turn Button do_orders() if numplay=1 then return end if curplay += 1 if curplay>numplay then curplay=1 end if Msg1="Player "&str_val(players[curplay]) copyBlt(Buffer,0,0,Buffer3) while ptype[players[curplay]] do comp_turn() end while Msg1="Player "&str_val(players[curplay]) gd=2 drawMap() copyBlt(Buffer3,0,0,Buffer) gd=0 repaintWindow(MyWindow) curcty=find(players[curplay],owner) Hilight1() setVisible(Button9,True) setEnable(Button9,True) setVisible(Button10,True) setEnable(Button10,True) setVisible(Group11,True) setEnable(Group11,True) setVisible(Button12,True) setEnable(Button12,True) setVisible(Button13,False) setEnable(Button13,False) setVisible(Button14,True) setEnable(Button14,True) setVisible(Scroll1,False) setEnable(Scroll1,False) setVisible(ScrollH1,False) orders=repeat(0,Cities) for i=1 to Cities do if owner[i]=players[curplay] then orders[i]=-1 end if end for repaintWindow(MyWindow) setCheck(Button11A,True) setCheck(Button11B,False) end procedure ---------------------------------------------------------------------------- procedure onScroll1(integer p1) setText(ScrollH1,"armies: "&str_val(p1)) if sequence(orders[curcty]) then orders[curcty][1]=p1 else orders[curcty]={p1,1} end if repaintWindow(MyWindow) end procedure ---------------------------------------------------------------------------- procedure Init() setPenColor(Buffer,BrightWhite) drawRectangle(Buffer,True,0,0,800,580) Msg1="Welcome to Conquest" repaintWindow(MyWindow) end procedure ---------------------------------------------------------------------------- procedure onMenu_About() -- About menu item on Help menu integer result result = message_box("Conquest"&13&10& "A Semi-Abstract Wargame"&13&10& " "&13&10& " Programmed by Mark K. Akita"&13&10& " using EUPHORIA v2.2"&13&10& "Developed using David Cuny's Win32Lib"&13&10& "Updated by Jordan Bell", "About Conquest", MB_ICONINFORMATION+MB_TASKMODAL ) end procedure ---------------------------------------------------------------------------- Msg1="" onClick[Exit] = routine_id("onMenu_Exit") onClick[New] = routine_id("onMenu_New") onClick[About] = routine_id("onMenu_About") onPaint[MyWindow] = routine_id("Redraw") onOpen[MyWindow] = routine_id("Init") onClick[Button7] = routine_id("onButton7") -- OK to start new game onClick[Button8] = routine_id("onButton8") -- Cancel new game start onClick[Button9] = routine_id("onButton9") -- Previous country onClick[Button10] = routine_id("onButton10") -- Next Country onClick[Button11A] = routine_id("onButton11A") -- Build onClick[Button11B] = routine_id("onButton11B") -- Move onClick[Button12] = routine_id("onButton12") -- Previous destination onClick[Button13] = routine_id("onButton13") -- Next destination onClick[Button14] = routine_id("onButton14") -- End Turn onScroll[Scroll1] = routine_id("onScroll1") -- Units to move WinMain(MyWindow,Normal)