Author Topic: Re: CONFLICT - A POLITICAL STRATEGIC SIMULATION GAME (STILL IN PROGRESS)  (Read 1170 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Hi Ron,

Starting with stuff in OnLoad, all that stuff should divided into Menu Screens not saved into arrays

Sub MenuGovernment

Sub MenuForeign ( i before e except when foreign)

Sub MenuMilitary

Sub MenuEconomics

THEN the game loops around probably back to Government so main loop

Do
     Show some news
     Call Government sub - which jobs out to foreign, military, economics ie calls the various sub menu subs
Loop

Each of these Menu subs presents a menu gets a key, executes an action.. so what you are calling DATA statements should be PRINT statements in a SUB Menu, present the Menu, getKey choice execute that action. PS don't offer choices that are no longer available.

You would have to explain in regular English what the Foreign Ministry is supposed to do because I haven't a clue from the variables in that sub.
« Last Edit: November 14, 2019, 09:58:41 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: CONFLICT - A POLITICAL STRATEGIC SIMULATION GAME (STILL IN PROGRESS)
« Reply #1 on: November 14, 2019, 10:19:04 pm »
After running code it seems I am supposed to visit each department and decide something and then next bit of news comes up, why not just make it a round, visit dept 1, then 2, then 3 instead of being told I did that department already?

Marked as best answer by ron77 on November 18, 2019, 06:00:41 am

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: CONFLICT - A POLITICAL STRATEGIC SIMULATION GAME (STILL IN PROGRESS)
« Reply #2 on: November 15, 2019, 01:00:06 am »
Good, ours are very similar but I have no idea what you intended for the peace stuff...
Code: QB64: [Select]
  1. _TITLE "CONFLICT - SIMULATION GAME" 'started by ron77 on 11-12-2019 - made a working skeleton of subs... need more work to be complited
  2. REDIM SHARED news$(0)
  3. DIM SHARED GovernmentType$, MilitaryAction$, ForeignAction$, EconomicAction$
  4.  
  5. loadNews
  6. Opening
  7.     CLS
  8.     PRINT NewsUpdate$
  9.     PRINT: INPUT "Press enter when you have read the latest news... "; wayt$
  10.     Military
  11.     Foreign
  12.     Economics
  13.  
  14. SUB Opening
  15.     cp 4, "COMFLICT - STRATEGIC POLITICAL SIMULATION"
  16.     cp 6, "BY RON77"
  17.     COLOR 31: cp 8, "PRESS ANY KEY 1 TO BEGIN OR ESC KEY TO EXIT": COLOR 7
  18.     k$ = GetKey$("1" + CHR$(27))
  19.     IF k$ = CHR$(27) THEN END
  20.  
  21.     CLS
  22.     cp 3, "YOU ARE THE NEWLY ELECTED PRIME MINISTER OF THE STATE OF ISRAEL"
  23.     cp 5, "YOU PROMISSED THE ISRAELI VOTERS - 'PEACE AND SECURITY'"
  24.     cp 7, "HOWEVER THE MIDDLE EAST IS BURNING FROM TERROR AND INSTABILITY"
  25.     cp 9, "HAMAS FROM GAZA AND HIZZBALLA FROM LEBANON AND IRAN ARE THRETHENING"
  26.     cp 11, "TO DESTROY ISRAEL AND KILL ALL ISRAELIS"
  27.     cp 13, "THE FAITH OF THE ISRAELI NATION IS IN YOUR HANDS"
  28.     cp 15, "MAY GOD BE WITH YOU! - GOOD LUCK!"
  29.     cp 19, "press any to continue..."
  30.     SLEEP
  31.  
  32.     CLS
  33.     cp 3, "WHAT TYPE OF GOVERNMENT WILL YOU MAKE?"
  34.     lp 5, 2, "1. MAKE A LEFT WING GOVERNMENT AND TRY TO ACHIVE PEACE WITH THE ARAB WORLD"
  35.     lp 6, 2, "2. MAKE A CONSERVATIVE CENTER GOVERNMENT THAT WILL TRY TO MAINTAINE STABILITY"
  36.     lp 7, 2, "3. MAKE A RIGHT WING GOVERNMENT THAT WILL FIGHT ISRAEL'S ENEMIES"
  37.     cp 9, "PLEASE CHOOSE 1 2 OR 3 KEYS"
  38.     TypeGovernment$ = GetKey$("123") '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> where does this get used????
  39.  
  40. SUB Military
  41.     CLS
  42.     cp 2, "THE MILITARY IS WAITING FOR YOUR ORDERS SIR!"
  43.     lp 4, 2, "1. ASSASINATE A KEY FIGURE IN HAMAS\HIZZBALLA\IRAN MILITERY ORGANIZATION"
  44.     lp 5, 2, "2. OPEN A LIMITED MILITERY OPERATION AGAINST HAMAS\HIZZBALLA"
  45.     lp 6, 2, "3. BOMB STRATEGIC TARGETS IN IRAN TO DESTROY NUCLEAR FACILITIES"
  46.     lp 7, 2, "4. TRY TO DISTABLIZED IRAN\HAMAS\HIZZBALLA BY GIVING AID TO REBEL OPOSITION"
  47.     lp 8, 2, "5. DO NOTHING FOR THE MOMENT - LET'S WAIT AND SEE HOW THINGS DEVELOP"
  48.     cp 10, "CHOOSE 1 2 3 4 OR 5 KEYS"
  49.     MilitaryAction$ = GetKey$("12345")
  50.  
  51. SUB Foreign
  52.     CLS
  53.     cp 2, "FOREIGN AFFAIRS MINISTER AT YOUR SERVICE. SIR!"
  54.     lp 4, 2, "1. START A SECRET NEGOTIOATION CHANNEL WITH HAMAS\HIZZBALLA\IRAN"
  55.     lp 5, 2, "2. ASK THE U.N. SECURITY COUNCIL TO CONDEMN AND SANCTION IRAN\HAMAS\HIZZBALLA"
  56.     lp 6, 2, "3. ASK THE U.S. FOR AID"
  57.     lp 7, 2, "4. TRY TO INCREASE WORLD SUPPORT FOR ISRAEL BY MAKING A SPEECH IN THE U.N."
  58.     lp 8, 2, "5. FIND ALLIES IN OTHER COUNTRIES WHO ARE ENEMIES OF IRAN\HAMAS\HIZZBALLA"
  59.     lp 9, 2, "6. DO NOTHING FOR THE MOMENT - LET'S WAIT AND SEE HOW THINGS DEVELOP"
  60.     cp 11, "CHOOSE 1 2 3 4 5 OR 6"
  61.     ForeignAction$ = GetKey$("123456")
  62.  
  63. SUB Economics
  64.     CLS
  65.     cp 2, "THE ECONOMIC CABINET IS READY TO MEET YOU PRIME MINISTER"
  66.     lp 4, 2, "1. INCREASE DEFENCE BUDGET AND RAISE TAXS"
  67.     lp 5, 2, "2. DECREASE DEFENCE BUDGET AND LOWER TAXS"
  68.     lp 6, 2, "3. LEAVE THE BUDGET AS IT IS FOR NOW"
  69.     lp 8, 2, "CHOOSE 1 2 OR 3"
  70.     EconomicAction$ = GetKey$("123")
  71.  
  72. FUNCTION peace$ (n) ' how to make a function out of a string array!!!
  73.     SELECT CASE n
  74.         CASE 1: peace$ = "WE HAVE STARTED TO NEGOTIATE SECRETLY WITH THE IRANIANS. PROGRESS IS SLOW. IT WILL TAKE TIME"
  75.         CASE 2: peace$ = "WE ARE NEGOTIATING WITH THE IRANIANS BUT IT LOOKS LIKE THEY ARE DELAYING ON PURPOSE TIME WHILE THE NEGOTIATION IS STUCK"
  76.         CASE 3: peace$ = "THERE IS CONCERN THAT THE SECRET CHANNEL BETWEEN US AND THE IRANIANS WILL LEAK TO THE PRESS. IF SO THIS MAY PUT AN END TO THE NEGOTIATIONS"
  77.         CASE 4: peace$ = "THE NEGOTIATION TEAMS BETWEEN US AND IRAN HAVE DONE SOME PROGRESS... WE NEED MORE TIME"
  78.         CASE 5: peace$ = "WE ARE CLOSE TO A PEACE AGREEMENT BETWEEN US AND THE IRANIANS TO END ALL HOSTILITY JUST A FEW MORE DETILES"
  79.         CASE 6: peace$ = "WE HAVE A PEACE AGREEMENT READY BETWEEN US AND THE IRANIANS - ARE YOU READY TO SIGN IT?"
  80.     END SELECT
  81.  
  82. 'FUNCTION peace2$
  83. '    'IF agreement = 0 THEN
  84. '    IF pco < 6 THEN
  85. '        forin(2) = "1. WE ARE CORRENTLY NEGOTIATING SECRETLT WITH IRAN\HAMAS\HIZZBALLA. SHELL WE STOP THE NEGOTITATIONS?"
  86. '        'ELSEIF pco = 6 THEN
  87. '        '    forin(2) = "1. SIGN A PEACE AGREEMENT WITH IRAN\HAMAS\HIZZBALLA"
  88. '        pco = pco + 1
  89. '        n$ = peace(pco)
  90. '        peace2$ = n$
  91. '    ELSEIF pco > 6 THEN
  92. '        pco = 6
  93. '        'n$ = peace(pco)
  94. '        'peace2$ = n$
  95. '    ELSEIF pco = 6 THEN
  96. '        n$ = peace(pco)
  97. '        peace2$ = n$
  98. '        forin(2) = "1. SIGN A PEACE AGREEMENT WITH IRAN\HAMAS\HIZZBALLA"
  99. '        offSwitch1 = 3
  100. '        'agreement = -1
  101. '        'Pcount = 0
  102. '    END IF
  103. '    'ELSEIF agreement = -1 THEN
  104. '    '    forin(2) = "1. YOU HAVE SIGNED A PEACE AGREEMENT WITH IRAN\HAMAS\HIZZBALLA SHELL WE BREACK THE AGREEMENT?"
  105. '    '    peace2$ = "WE HAVE SIGN A PEACE AGREEMENT WITH ALL OF OUR ENEMIES. NO MORE WAR NO MORE BLOODSHED"
  106. '    'END IF
  107. 'END SUB
  108.  
  109. SUB loadNews 'don't try to cp these lines, they are too long
  110.     REDIM news$(1 TO 9)
  111.     news$(1) = "HAMAS HAS LUNCHED MISSILES TO THE SOUTHEREN BORDER THE PUBLIC DEMANDS ACTION"
  112.     news$(2) = "HIZZBALLA HAS ATTACKED A BASE NEAR THE NORTHEN BORDER 2 OF OUR SOLDIERS ARE MISSING - WHAT SHELL BE OUR RESPONSE?"
  113.     news$(3) = "IRAN IS BUILDING A NUCLEAR SITE FOR PLUTONIUM WITHIN A FEW YEARS THEY WILL HAVE AN ATOMIC WEPONE AGAINST US - WE MUST DO SOMETHING!"
  114.     news$(4) = "HAMAS HAS SECRETLY CONTACTED THE FORINE AFFAIRS OFFICE WITH A MESSAGE THEY WANT PEACE AND STABILITY - SHELL WE NEGOTIATE?"
  115.     news$(5) = "THE U.S. PRESIDENT HAS ASKED US TO CONSIDER A PEACE DEAL WITH IRAN - IN RETURN THE U.S. WILL EQUIPTE OUR ARMY WITH THE LATEST WEPONES AND INCREASE THE MILITERY AID"
  116.     news$(6) = "OUR ECONOMY IS NOT DOING GOOD WE SPEND TOO MUCH MONEY ON THE MILITERY - WE NEED TO CHOOSE EITHER MORE TAXS OR DECREASE SPENDING"
  117.     news$(7) = "IRAN PRESIDENT HAS SAID THAT 'ISRAEL MUST AND WILL BE ERASED FROM THE MAP!' - HOW SHELL WE RESPOND TO THIS PROVOCATION?"
  118.     news$(8) = "IRANIAN DIPLOMATES HAVE CONTACTED THE FORINE AFFAIRS AMBASSADOR IN CHILE AND ASKED TO OPEN A SECRET NEGOTIATION - SHELL WE AGREE?"
  119.     news$(9) = "OUR ECONOMY IS BOOMING AND FLURISHING WE NEED TO DISIDE EITHER TO INCREASE DEFENCE BUDGET OR MAYBE DECRESE TAXS"
  120.  
  121. FUNCTION NewsUpdate$ ()
  122.     NewsUpdate$ = news$(INT(RND * 9) + 1)
  123.  
  124. 'cp needs s$ to be less that width of screen
  125. SUB cp (row, s$)
  126.     LOCATE row, INT((_WIDTH - LEN(s$)) / 2): PRINT s$;
  127.  
  128. SUB lp (row, col, s$)
  129.     LOCATE row, col: PRINT s$;
  130.  
  131. FUNCTION GetKey$ (keysToCatch$)
  132.     DIM k$
  133.     DO
  134.         k$ = INKEY$
  135.         WHILE LEN(k$) = 0
  136.             k$ = INKEY$
  137.             _LIMIT 60
  138.         WEND
  139.     LOOP UNTIL INSTR(keysToCatch$, k$)
  140.     GetKey$ = k$
  141.  
  142.  

I would guess after meeting with the 3 government departments those departments would handle your orders.
Instead of calling your choices k2$, k3$, k4$...  use Shared MilitaryAction$, ForeignAction$, EconomicAction$ so you can do more coding for those actions if you want.

« Last Edit: November 15, 2019, 01:02:53 am by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: CONFLICT - A POLITICAL STRATEGIC SIMULATION GAME (STILL IN PROGRESS)
« Reply #3 on: November 15, 2019, 03:06:00 pm »
Hi Ron,

You know we've followed a recipe for creating a menu sub:

Show a title, offer n amount of options then get the users choice coded into a single number or digit... get all the text centered nicely on the page/screen

If you are stuck on what next to do with the game, you could work on problem of writing a generic screen menu function and go back to loading arrays from DATA given a key data lookup (Restore line label) or use the key to pull data out of a txt file like done with ELIZA/Player.

So what we've repeated 3x's, we could do once over and over again in this game and any other like it.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: CONFLICT - A POLITICAL STRATEGIC SIMULATION GAME (STILL IN PROGRESS)
« Reply #4 on: November 15, 2019, 04:25:53 pm »
The game is boring when the options remain the same and the news is random, as options and news change according decisions you make in the game, the game could get very interesting.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: CONFLICT - A POLITICAL STRATEGIC SIMULATION GAME (STILL IN PROGRESS)
« Reply #6 on: November 16, 2019, 10:09:48 pm »
Code to reduce length of dates1$ function

Code: QB64: [Select]
  1. ' code to test dates1$
  2.     INPUT "Enter a month number 1 to 100 "; mn
  3.     PRINT dates1$(mn)
  4. LOOP UNTIL mn = 0
  5.  
  6. FUNCTION month$ (n) 'for dates1$ function
  7.     RESTORE 4
  8.     FOR i = 1 TO n
  9.         READ month$
  10.     NEXT
  11.    4 DATA JANUARY,FEBRUARY,MARCH,APRIL,MAY,JUNE,JULY,AUGUST,SEPTEMBER,OCTOBER,NOVEMBER,DECEMBER
  12.  
  13. FUNCTION dates1$ (months)
  14.     m = months MOD 12
  15.     IF m = 0 THEN m = 12
  16.     dates1$ = month$(m) + "," + STR$(INT((months - 1) / 12) + 2027)

So it's true, you don't need quotes around strings in DATA, nice.
« Last Edit: November 16, 2019, 10:37:54 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: CONFLICT - A POLITICAL STRATEGIC SIMULATION GAME (STILL IN PROGRESS)
« Reply #7 on: November 17, 2019, 12:37:03 am »
Hi Ron,

I was curious if I could get a generic MenuChoice% Function going. I did. Here is what your code looks like with that (didn't mess with Foreign because you are changing the options in that sub) Oh I installed a Meet Menu because it is usually just 1 department you want to meet with to respond to latest news (as far as I can tell).

Code: QB64: [Select]
  1. _TITLE "CONFLICT - SIMULATION GAME" 'started by ron77 on 11-12-2019 - made a working skeleton of subs... need more work to be complited
  2. '11-16-2019 continuing working on the game with help of bplus and my teacher. added functions for more options bottens...
  3. 'added time scale for how long the game will be played...
  4.  
  5. DEFINT A-Z
  6. REDIM SHARED news$(0), options$(0) ', un$(0)
  7. DIM SHARED GovernmentType, MilitaryAction, ForeignAction$, EconomicAction, PeaceButtonIndicator AS INTEGER, PeaceProssessCounter AS INTEGER
  8. PeaceButtonIndicator = 1
  9. PeaceProssessCounter = 1
  10. time = 1
  11.  
  12. loadNews
  13. 'UnCouncil
  14. Opening
  15.     CLS
  16.     cp 2, dates1$(time): PRINT: PRINT
  17.     time = time + 1
  18.     PRINT NewsUpdate$
  19.     PRINT: INPUT "Press enter when you have read the latest news... "; wayt$
  20.     dept = menuChoice("Meet")
  21.     SELECT CASE dept
  22.         CASE 1: MilitaryAction = menuChoice("Military")
  23.         CASE 2: EconomicAction = menuChoice("Economic")
  24.         CASE 3: Foreign
  25.     END SELECT
  26. LOOP UNTIL time = 49
  27.  
  28. SUB Opening
  29.     cp 4, "CONFLICT - STRATEGIC POLITICAL SIMULATION"
  30.     cp 6, "BY RON77 AND Bplus AND ITAY"
  31.     COLOR 31: cp 8, "PRESS ANY KEY 1 TO BEGIN OR ESC KEY TO EXIT": COLOR 7
  32.     k$ = GetKey$("1" + CHR$(27))
  33.     IF k$ = CHR$(27) THEN END
  34.  
  35.     CLS
  36.     cp 3, "YOU ARE THE NEWLY ELECTED PRIME MINISTER OF THE STATE OF ISRAEL"
  37.     cp 5, "YOU PROMISSED THE ISRAELI VOTERS - 'PEACE AND SECURITY'"
  38.     cp 7, "HOWEVER THE MIDDLE EAST IS BURNING FROM TERROR AND INSTABILITY"
  39.     cp 9, "HAMAS FROM GAZA AND HIZZBALLA FROM LEBANON AND IRAN ARE THRETHENING"
  40.     cp 11, "TO DESTROY ISRAEL AND KILL ALL ISRAELIS"
  41.     cp 13, "THE FAITH OF THE ISRAELI NATION IS IN YOUR HANDS"
  42.     cp 15, "MAY GOD BE WITH YOU! - GOOD LUCK!"
  43.     cp 19, "press any to continue..."
  44.     SLEEP
  45.  
  46.     GovernmentType = menuChoice("Government")
  47.  
  48.  
  49. SUB Foreign
  50.  
  51.     IF PeaceButtonIndicator = 2 AND PeaceProssessCounter < 6 THEN
  52.         p$ = peace$(PeaceProssessCounter)
  53.         'PRINT p$
  54.         PeaceProssessCounter = PeaceProssessCounter + 1
  55.     ELSEIF PeaceProssessCounter >= 6 THEN
  56.         p$ = peace$(PeaceProssessCounter)
  57.     END IF
  58.  
  59.     SELECT CASE PeaceButtonIndicator
  60.         CASE 1: PeaceButton$ = "1. START A SECRET NEGOTIOATION CHANNEL WITH HAMAS\HIZZBALLA\IRAN"
  61.         CASE 2: PeaceButton$ = "1. WE ARE NEGOTITATHING SECRETLY WITH THE IRANIANS, SHELL WE STOP?"
  62.         CASE 3: PeaceButton$ = "1. SIGN A PEACE AGREEMENT WITH IRAN\HAMAS\HIZZBALLA"
  63.         CASE 4: PeaceButton$ = "1. BREAK THE PEACE AGREEMENT WITH IRAN\HAMAS\HIZZBALLA"
  64.     END SELECT
  65.     CLS
  66.     cp 2, "FOREIGN AFFAIRS MINISTER AT YOUR SERVICE. SIR!"
  67.     lp 4, 2, PeaceButton$
  68.     lp 5, 2, "2. ASK THE U.N. SECURITY COUNCIL TO CONDEMN AND SANCTION IRAN\HAMAS\HIZZBALLA"
  69.     lp 6, 2, "3. ASK THE U.S. FOR AID"
  70.     lp 7, 2, "4. TRY TO INCREASE WORLD SUPPORT FOR ISRAEL BY MAKING A SPEECH IN THE U.N."
  71.     lp 8, 2, "5. FIND ALLIES IN OTHER COUNTRIES WHO ARE ENEMIES OF IRAN\HAMAS\HIZZBALLA"
  72.     lp 9, 2, "6. DO NOTHING FOR THE MOMENT - LET'S WAIT AND SEE HOW THINGS DEVELOP"
  73.     cp 11, "CHOOSE 1 2 3 4 5 OR 6"
  74.     PRINT
  75.     PRINT p$
  76.     PRINT
  77.  
  78.  
  79.     ForeignAction$ = GetKey$("123456")
  80.     IF ForeignAction$ = "1" AND PeaceButtonIndicator = 1 THEN
  81.         PeaceButtonIndicator = 2
  82.     ELSEIF ForeignAction$ = "1" AND PeaceButtonIndicator = 2 AND PeaceProssessCounter < 6 THEN
  83.         PeaceButtonIndicator = 1
  84.         PeaceProssessCounter = 1
  85.     ELSEIF PeaceButtonIndicator = 2 AND PeaceProssessCounter = 6 THEN
  86.         PeaceButtonIndicator = 3
  87.     ELSEIF ForeignAction$ = "1" AND PeaceButtonIndicator = 3 THEN
  88.         PeaceButtonIndicator = 4
  89.         PeaceProssessCounter = 7
  90.     ELSEIF ForeignAction$ = "1" AND PeaceButtonIndicator = 4 THEN
  91.         PeaceButtonIndicator = 1
  92.         PeaceProssessCounter = 1
  93.     END IF
  94.  
  95.     IF ForeignAction$ = "2" THEN
  96.         PRINT UnCouncil$(INT(RND * 4) + 1)
  97.         PRINT
  98.         SLEEP
  99.     END IF
  100.     IF ForeignAction$ = "3" THEN
  101.         PRINT UsAid$(INT(RND * 6) + 1)
  102.         PRINT
  103.         SLEEP
  104.     END IF
  105.  
  106. FUNCTION peace$ (n) ' how to make a function out of a string array!!!
  107.     SELECT CASE n
  108.         CASE 1: peace$ = "WE HAVE STARTED TO NEGOTIATE SECRETLY WITH THE IRANIANS. PROGRESS IS SLOW. IT WILL TAKE TIME"
  109.         CASE 2: peace$ = "WE ARE NEGOTIATING WITH THE IRANIANS BUT IT LOOKS LIKE THEY ARE DELAYING ON PURPOSE TIME WHILE THE NEGOTIATION IS STUCK"
  110.         CASE 3: peace$ = "THERE IS CONCERN THAT THE SECRET CHANNEL BETWEEN US AND THE IRANIANS WILL LEAK TO THE PRESS. IF SO THIS MAY PUT AN END TO THE NEGOTIATIONS"
  111.         CASE 4: peace$ = "THE NEGOTIATION TEAMS BETWEEN US AND IRAN HAVE DONE SOME PROGRESS... WE NEED MORE TIME"
  112.         CASE 5: peace$ = "WE ARE CLOSE TO A PEACE AGREEMENT BETWEEN US AND THE IRANIANS TO END ALL HOSTILITY JUST A FEW MORE DETILES"
  113.         CASE 6: peace$ = "WE HAVE A PEACE AGREEMENT READY BETWEEN US AND THE IRANIANS - ARE YOU READY TO SIGN IT?"
  114.         CASE 7: peace$ = "WE HAVE SIGN A PEACE AGREEMENT WITH IRAN\HAMAS\HIZZBALLA. NOT MORE WAR NO MORE BLOODSHED!"
  115.     END SELECT
  116.  
  117. 'SUB UnCouncil
  118. '    REDIM un$(1 TO 4)
  119. '    un$(1) = "THE U.N. COUNCIL HAS REJECTED OUR REQUEST FOR CONDEMMING IRAN OT HAMAS OR HIZZBLLA"
  120. '    un$(2) = "THE U.N. COUNCIL HAS REVERSED OUR REQUEST AND ADOPTED THE INDONASIAN'S REQUEST FOR CONDOMMING ISRAEL AS AN AGGRESSIVE APARTHIDE RACIST STATE"
  121. '    un$(3) = "OUR REQUEST HAS REACHED TO THE SECURITY COUNCIL OF THE U.N. BUT A VETO BY RUSSIA AND CHINA HAS CANCELED ANY CHANCE OF CONDEMMING IRAN OR HIZZBALLA OR HAMAS AS TERROR ORGANIZATIONS"
  122. '    un$(4) = "THE SECURITY COUNCIL OF THE U.N. HAD VOTED AGAINST IRAN AND HIZZBALLA AND HAMAS CALLING THEM A TERROR ORGANIZATIONS AND SAYING THAT ISRAEL HAS A RIGHT TO DEFEND ITSELF AND IT'S CITIZENS"
  123. 'END SUB
  124.  
  125.  
  126. FUNCTION UnCouncil$ (n)
  127.     'REDIM un$(1 TO 4)
  128.     SELECT CASE n
  129.         CASE 1: UnCouncil$ = "THE U.N. COUNCIL HAS REJECTED OUR REQUEST FOR CONDEMMING IRAN OT HAMAS OR HIZZBLLA"
  130.         CASE 2: UnCouncil$ = "THE U.N. COUNCIL HAS REVERSED OUR REQUEST AND ADOPTED THE INDONASIAN'S REQUEST FOR CONDOMMING ISRAEL AS AN AGGRESSIVE APARTHIDE RACIST STATE"
  131.         CASE 3: UnCouncil$ = "OUR REQUEST HAS REACHED TO THE SECURITY COUNCIL OF THE U.N. BUT A VETO BY RUSSIA AND CHINA HAS CANCELED ANY CHANCE OF CONDEMMING IRAN OR HIZZBALLA OR HAMAS AS TERROR ORGANIZATIONS"
  132.         CASE 4: UnCouncil$ = "THE SECURITY COUNCIL OF THE U.N. HAD VOTED AGAINST IRAN AND HIZZBALLA AND HAMAS CALLING THEM A TERROR ORGANIZATIONS AND SAYING THAT ISRAEL HAS A RIGHT TO DEFEND ITSELF AND IT'S CITIZENS"
  133.     END SELECT
  134.  
  135. FUNCTION UsAid$ (n)
  136.     SELECT CASE n
  137.         CASE 1: UsAid$ = "IT IS AN ELECTION YEAR IN THE USA SO YOU ARE SUCCESSFUL IN WINING SUPPORT FOR ISRAEL SENATORS AND CONGRESSMANS PROMISS TO INCRESS AID AND SUPPORT FOR ISRAEL AND AGINST IRAN AND HAMAS AND HIZZBALLA"
  138.         CASE 2: UsAid$ = "THE US CONGRESS AND SENATE PASS A LAW TO BAN IRAN AND HAMAS AND HIZZBALLA AND DECLEARE THEM AS TERROR ORGANIZATIONS"
  139.         CASE 3: UsAid$ = "YOU ARE INVITED TO THE WHITE HOUSE FOR AN PHOTO-OP WITH THE U.S. PRESIDENT BESIDES THAT YOU ACHIVE ALMOST NOTHING 'WE SUPPORT YOU AND AID YOU ENOGH' SAYS TO YOU THE PRESIDENT BEHIND CLOSE DOORS"
  140.         CASE 4: UsAid$ = "THE U.S. PRESIDENT APPEARS IN A PRESS PARTY AND DECLEARE 'ISRAEL HAS THE RIGHT TO DEFEND ITSELF AND ISRAELIS HAVE A RIGHT TO LIVE IN PEACE AND SECURITY"
  141.         CASE 5: UsAid$ = "THE U.S.A. IS OCCUPY BY IT'S OWN PROBLEMS. THE U.S. AMBASSADOR TELLS YOU IT'S NOT A GOOD TIME TO ASK FOR AID OF ANY KIND FROM THE U.S."
  142.         CASE 6: UsAid$ = "THE U.S.A. GOVERNMENT DICIDED TO INCREASE IT'S FOREIGN AID TO ISRAEL"
  143.     END SELECT
  144.  
  145. SUB loadNews 'don't try to cp these lines, they are too long
  146.     REDIM news$(1 TO 9)
  147.     news$(1) = "HAMAS HAS LUNCHED MISSILES TO THE SOUTHEREN BORDER THE PUBLIC DEMANDS ACTION"
  148.     news$(2) = "HIZZBALLA HAS ATTACKED A BASE NEAR THE NORTHEN BORDER 2 OF OUR SOLDIERS ARE MISSING - WHAT SHELL BE OUR RESPONSE?"
  149.     news$(3) = "IRAN IS BUILDING A NUCLEAR SITE FOR PLUTONIUM WITHIN A FEW YEARS THEY WILL HAVE AN ATOMIC WEPONE AGAINST US - WE MUST DO SOMETHING!"
  150.     news$(4) = "HAMAS HAS SECRETLY CONTACTED THE FORINE AFFAIRS OFFICE WITH A MESSAGE THEY WANT PEACE AND STABILITY - SHELL WE NEGOTIATE?"
  151.     news$(5) = "THE U.S. PRESIDENT HAS ASKED US TO CONSIDER A PEACE DEAL WITH IRAN - IN RETURN THE U.S. WILL EQUIPTE OUR ARMY WITH THE LATEST WEPONES AND INCREASE THE MILITERY AID"
  152.     news$(6) = "OUR ECONOMY IS NOT DOING GOOD WE SPEND TOO MUCH MONEY ON THE MILITERY - WE NEED TO CHOOSE EITHER MORE TAXS OR DECREASE SPENDING"
  153.     news$(7) = "IRAN PRESIDENT HAS SAID THAT 'ISRAEL MUST AND WILL BE ERASED FROM THE MAP!' - HOW SHELL WE RESPOND TO THIS PROVOCATION?"
  154.     news$(8) = "IRANIAN DIPLOMATES HAVE CONTACTED THE FORINE AFFAIRS AMBASSADOR IN CHILE AND ASKED TO OPEN A SECRET NEGOTIATION - SHELL WE AGREE?"
  155.     news$(9) = "OUR ECONOMY IS BOOMING AND FLURISHING WE NEED TO DISIDE EITHER TO INCREASE DEFENCE BUDGET OR MAYBE DECRESE TAXS"
  156.  
  157. FUNCTION NewsUpdate$ ()
  158.     'cp 2, dates1$(time)
  159.     'PRINT
  160.     NewsUpdate$ = news$(INT(RND * 9) + 1)
  161.     'time = time + 1
  162.  
  163. 'cp needs s$ to be less that width of screen
  164. SUB cp (row, s$)
  165.     LOCATE row, INT((_WIDTH - LEN(s$)) / 2): PRINT s$;
  166.  
  167. SUB lp (row, col, s$)
  168.     LOCATE row, col: PRINT s$;
  169.  
  170. FUNCTION GetKey$ (keysToCatch$)
  171.     DIM k$
  172.     DO
  173.         k$ = INKEY$
  174.         WHILE LEN(k$) = 0
  175.             k$ = INKEY$
  176.             _LIMIT 60
  177.         WEND
  178.     LOOP UNTIL INSTR(keysToCatch$, k$)
  179.     GetKey$ = k$
  180.  
  181. FUNCTION month$ (n) 'for dates1$ function
  182.     RESTORE 4
  183.     FOR i = 1 TO n
  184.         READ month$
  185.     NEXT
  186.    4 DATA JANUARY,FEBRUARY,MARCH,APRIL,MAY,JUNE,JULY,AUGUST,SEPTEMBER,OCTOBER,NOVEMBER,DECEMBER
  187.  
  188. FUNCTION dates1$ (months)
  189.     m = months MOD 12
  190.     IF m = 0 THEN m = 12
  191.     dates1$ = month$(m) + "," + STR$(INT((months - 1) / 12) + 2027)
  192.  
  193. SUB sAppend (arr() AS STRING, item AS STRING)
  194.     REDIM _PRESERVE arr(LBOUND(arr) TO UBOUND(arr) + 1) AS STRING
  195.     arr(UBOUND(arr)) = item
  196.  
  197. FUNCTION menuChoice% (menu$)
  198.     SELECT CASE menu$ 'what list of options do we retore data line to?
  199.         CASE IS = "Government": RESTORE Gov
  200.         CASE IS = "Military": RESTORE Mil
  201.         CASE IS = "Economic": RESTORE Econ
  202.         CASE IS = "Meet": RESTORE Meet
  203.     END SELECT
  204.     REDIM options$(1)
  205.     READ options$(1)
  206.     DO
  207.         READ r$
  208.         IF r$ <> "endOfData" THEN sAppend options$(), r$
  209.     LOOP UNTIL r$ = "endOfData"
  210.     'redim shared Options$() call load Options$ can't get more than 9 options
  211.     CLS
  212.     lb = LBOUND(options$): ub = UBOUND(options$)
  213.     nOptions = ub - lb + 1
  214.     row = (25 - nOptions - 4) \ 2
  215.     cp row, options$(1) 'option 1 is title
  216.     row = row + 2
  217.     FOR i = 2 TO ub
  218.         lp row, 2, options$(i)
  219.         row = row + 1
  220.         digit = digit + 1
  221.         digits$ = digits$ + _TRIM$(STR$(digit))
  222.     NEXT
  223.     row = row + 1
  224.     cp row, "Please enter the option number of your choice "
  225.     menuChoice% = VAL(GetKey$(digits$))
  226.  
  227.     Gov:
  228.     DATA WHAT TYPE OF GOVERNMENT WILL YOU MAKE?
  229.     DATA 1. MAKE A LEFT WING GOVERNMENT AND TRY TO ACHIVE PEACE WITH THE ARAB WORLD
  230.     DATA 2. MAKE A CONSERVATIVE CENTER GOVERNMENT THAT WILL TRY TO MAINTAINE STABILITY
  231.     DATA 3. MAKE A RIGHT WING GOVERNMENT THAT WILL FIGHT ISRAEL'S ENEMIES
  232.     DATA endOfData
  233.  
  234.     Meet:
  235.     DATA WHO SHALL WE CALL FOR A MEETING TO RESPOND TO LATEST NEWS
  236.     DATA 1. MILITARY LEADERS
  237.     DATA 2. ECONOMIC EXECUTIVES
  238.     DATA 3. FOREIGN AMBASSADORS
  239.     DATA endOfData
  240.  
  241.     Mil:
  242.     DATA THE MILITARY IS WAITING FOR YOUR ORDERS SIR!
  243.     DATA 1. ASSASINATE A KEY FIGURE IN HAMAS\HIZZBALLA\IRAN MILITERY ORGANIZATION
  244.     DATA 2. OPEN A LIMITED MILITERY OPERATION AGAINST HAMAS\HIZZBALLA
  245.     DATA 3. BOMB STRATEGIC TARGETS IN IRAN TO DESTROY NUCLEAR FACILITIES
  246.     DATA 4. TRY TO DISTABLIZED IRAN\HAMAS\HIZZBALLA BY GIVING AID TO REBEL OPOSITION
  247.     DATA 5. DO NOTHING FOR THE MOMENT - LET'S WAIT AND SEE HOW THINGS DEVELOP
  248.     DATA endOfData
  249.  
  250.     Econ:
  251.     DATA THE ECONOMIC CABINET IS READY TO MEET YOU PRIME MINISTER
  252.     DATA 1. INCREASE DEFENCE BUDGET AND RAISE TAXS
  253.     DATA 2. DECREASE DEFENCE BUDGET AND LOWER TAXS
  254.     DATA 3. LEAVE THE BUDGET AS IT IS FOR NOW
  255.     DATA endOfData

What is nice about menuChoice is that everything you need for displaying a menu and getting the key choice (in a number now) is there in the function including all the DATA for filling out the specific menus.

EDIT: this line
DATA data end
 is being  changed to this
DATA DATA END so the read loop was not stopping where it was programmed to stop.

Changed lines to endOfData
« Last Edit: November 17, 2019, 03:14:56 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: CONFLICT - A POLITICAL STRATEGIC SIMULATION GAME (STILL IN PROGRESS)
« Reply #8 on: November 17, 2019, 03:11:26 pm »
hi bplus :)

i integreted your improved dates1$ function to the games code and as for the generic MenuChoice% version of the game well...
when i run it i get right away an error message "out of DATA" on "line 224" in any case you are right when you wrote me that i should stick to the previous version (but including the improved dates1$ function) cuz i plan to be able to do dynamic changes to the military sub or economic sub  like i did with the foreign minister sub...

tonight it looks like i'm going to code further the game and by morning sunrise i'll post the code again...

ron77 

Oh ha! The forum code box changed:

DATA data end

to
DATA DATA END

Poor choice of words for end of data line. I will edit previous post.
« Last Edit: November 17, 2019, 03:16:54 pm by bplus »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: CONFLICT - A POLITICAL STRATEGIC SIMULATION GAME (STILL IN PROGRESS)
« Reply #9 on: November 17, 2019, 03:15:58 pm »
Oh ha! The forum code box changed:

DATA data end

to
DATA DATA END

Poor choice of words for end of data line. I will edit previous post.

EOD is what I normally use for End Of Data.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!