Advertisement
Guest User

Untitled

a guest
Jul 31st, 2015
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 37.55 KB | None | 0 0
  1. module Constantinople
  2.  
  3. # Global variables for battle engines
  4. # The battle engine methods had to be nested in their respective sections so
  5. # the randomizer will throw up a different number each time
  6. $luck_factor = 0.20
  7. $theodosian_walls = 15_000
  8. $ottoman_army = 200_000
  9. $eastern_roman_army = 15_000
  10. $city_pop = 50_000
  11. $western_reinforcements
  12. $wall_damage
  13.  
  14.  
  15. def game_intro # Introduces the game background
  16. puts <<-END
  17.  
  18. Welcome to ROMA ETERNA!
  19.  
  20. Will you see Nova Roma remain in Christian hands up to present or allow
  21. history to take its course and it becomes today's Istanbul?
  22.  
  23. The year is 1453, and centuries-old Constantinople, capital of the
  24. Eastern Roman Empire, grandest of all cities, Mistress of the East,
  25. and guardian of Europe and Christendom for a thousand years, is but a shadow
  26. of its former glory, and is being besieged by a powerful Turkish army,
  27. hundreds-of-thousands strong.
  28.  
  29. By this time, what remains of the realm that once ruled most of the known
  30. world has been reduced to a small sliver of land surrounding the immediate
  31. environs of the city.
  32.  
  33. There are no more Roman legions - those armies that conquered powerful
  34. empires and defended vast borders that kept the empire and its citizens
  35. prosperous and secure.
  36.  
  37. They exist only in lore and legend.
  38.  
  39. Your objective, as either Roman Emperor Constantine XI or
  40. Ottoman Sultan Memet II, is to ensure its survival or absolute conquest.
  41.  
  42. Your orders will be carried out by your most trusted advisors:
  43.  
  44. Strategoi Solomon of Delos and Agha Izmir of Aleppo, respectively.
  45.  
  46. HOW TO PLAY: Just enter letter in parentheses of your choice! GOOD LUCK!
  47.  
  48. Begin!
  49.  
  50. Choose side: play as (R)oman or (O)ttoman?
  51.  
  52. END
  53. end
  54. def game_play # Game proper
  55. case gets.chomp.downcase
  56. when 'r' # Player has chosen to be Roman
  57. sleep(3)
  58. puts <<-END
  59.  
  60. Strategoi Solomon: My lord Constantine, the Turks are upon us,
  61. and on you lies the destiny of our proud Roman race!
  62.  
  63. What is your command?
  64.  
  65. (N)egotiate, (f)ight, or (s)urrender the city?
  66.  
  67. END
  68. case gets.chomp.downcase
  69. when 'n' # Roman decides to negotiate
  70. sleep(3)
  71. puts <<-END
  72.  
  73. Sending ambassador Nicopherus to the enemy camp. We should hear from
  74. him shortly, that is, if he isn't beheaded sooner.
  75.  
  76. My lord, reports say Turkish demands are in. I am sending for their
  77. representatives, and here they are!
  78.  
  79. (P)ay a large tribute in gold, submit as a (v)assal to Memet II, or
  80. (c)onclude a treaty of friendship with him and give the hand of your
  81. eldest daughter, the Princess Theodora Porphyrogenita, in marriage
  82. to the Sultan's son and heir.
  83.  
  84. END
  85. case gets.chomp.downcase
  86. when 'p' # Roman will pay tribute
  87. sleep(3)
  88. puts <<-END
  89.  
  90. How much of the treasury do we give? Enter a number:
  91. (do not underestimate what gold will do to change people's minds).
  92.  
  93. END
  94. gold_amount = gets.to_i # Sets condition based on input from player
  95. if gold_amount < 1_000_000
  96. sleep(3)
  97. puts <<-END
  98.  
  99. You see?! I told you so - the Sultan deemed your offer an insult
  100. and has ordered his army to begin its assault! Your short-sightedness
  101. has brought closer our doom!
  102.  
  103. You are a disgrace! I myself will go out to lead the defense,
  104. and if through a miracle, we manage to win, I hope your
  105. Imperial Bodyguards have had the sense to evacuate
  106. you and your family from this place!
  107.  
  108. END
  109. def constantinople_attack # Battle engine
  110. $western_reinforcements = rand(50_000..75_000)
  111. if $western_reinforcements > 60_000
  112. sleep(3)
  113. puts <<-END
  114.  
  115. It is a good thing that reinforcements from the West are here! They are
  116. forming up to join our attack!
  117. END
  118. else
  119. sleep(3)
  120. puts <<-END
  121.  
  122. The West did send reinforcements. Let us hope they
  123. will be enough. We need all the help we can get.
  124. END
  125. end
  126. roman_attack = rand((150_000)..($ottoman_army)) - ($eastern_roman_army + $western_reinforcements)
  127. # Calculates battle results with randomizer for strengths of opposing armies due to
  128. #reinforcements and casualties, etc., and based on theory of 3 attackers vs. 1 defender
  129. sleep(5)
  130. msg = 'BATTLE IN PROGRESS! BATTLE IN PROGRESS!'
  131.  
  132. 15.times do
  133. print "\r#{ msg }"
  134. sleep 0.5
  135. print "\r#{ ' ' * msg.size }" # Flashes what is taking place.
  136. sleep 0.5
  137. end
  138.  
  139. if roman_attack > rand(90_000..110_000)
  140. sleep(3)
  141. puts <<-END
  142.  
  143. Praise God for this miracle! We have defeated the Turks!
  144. They were broken on our walls and are fleeing in disarray!
  145.  
  146. The gates have opened and our cavalry are in pursuit of
  147. survivors, and a detachment is right now searching for
  148. the Sultan and members of his court.
  149.  
  150. The city is delivered from conquest!
  151.  
  152. GAME OVER. ROMA ETERNA!
  153.  
  154. END
  155. else
  156. sleep(3)
  157. puts <<-END
  158.  
  159. DISASTER! Our army has been defeated! The Turks will surely
  160. breach our walls now and we have no more defenders left to man them!
  161.  
  162. Make ready to flee, my lord! There is a ship currently at harbor that is
  163. waiting to take you to Italy!
  164.  
  165. From there, you may seek help from The Pope in Rome to call for a
  166. crusade to retake our city!
  167.  
  168. Go now, for there is no time left!
  169.  
  170. GAME OVER. YOU LOSE!
  171.  
  172. END
  173. end
  174. end
  175. sleep(5)
  176. constantinople_attack() # Calls on battle engine to decide outcome
  177. else
  178. sleep(3)
  179. puts <<-END
  180.  
  181. Wise choice, Basileus. Because of your foresight, the Asiatic hordes
  182. have lifted the siege and are now breaking camp.
  183.  
  184. History will show that you will use this time wisely to
  185. rebuild Constantinople's empire, army and morale!
  186.  
  187. Praise God that no more need die today.
  188.  
  189. Congratulations!
  190.  
  191. GAME OVER. YOU WIN! ROMA ETERNA!
  192.  
  193. END
  194. end
  195. when 'v' # Roman will submit as a vassal
  196. sleep(3)
  197. puts <<-END
  198.  
  199. God help us! Constantinople never before has submitted to a
  200. foreign ruler! The Sultan expects you to send your army to
  201. fight for him whenever he calls. I am ashamed to call you Emperor!
  202.  
  203. There is a large body of men approaching the palace.
  204.  
  205. Guards! Secure this place.
  206.  
  207. END
  208. def coup_d_etat # Calculates chances of being deposed by unhappy Romans due to cowardice
  209. rand((0.1)..(0.25))
  210. end
  211. overthrow = coup_d_etat # What happens to you next
  212. to_percent = overthrow * 100
  213. sleep(5)
  214.  
  215. puts "The chance of a palace coup is: #{to_percent.floor}%!"
  216. if overthrow > 0.2
  217. sleep(3)
  218. puts <<-END
  219.  
  220. You have been deposed by your Imperial bodyguards, The Varangians!
  221. They will never bow to a foreign despot! You are about to be
  222. blinded and stripped of the Imperial regalia.
  223.  
  224. GAME OVER. YOU LOSE!
  225.  
  226. END
  227. else
  228. sleep(3)
  229. puts <<-END
  230.  
  231. That mob is your people wanting refuge within the safest
  232. place in the city when the Turks enter! Do you want to open
  233. the armories for a last-ditch defense, (y) or (n)?
  234. END
  235. final_defense = gets.chomp.downcase
  236. if final_defense === "y"
  237. citizen_army = ($city_pop * rand(0.0..0.25)) + $eastern_roman_army
  238. # Checks to see if can recruit from city_pop to add to eastern_roman_army and bolster city defense
  239. if citizen_army > $ottoman_army / rand(6..12)
  240. # Checks to see if enough troops have been raised to stand a chance at
  241. # successfully repelling invading ottoman_army
  242. sleep(3)
  243. puts <<-END
  244.  
  245. A new levy has been successfully raised and it is assembling
  246. in the main square, my lord Constantine. It numbers in the thousands!
  247.  
  248. The city may yet have hope!
  249.  
  250. Go out and lead them to victory!
  251.  
  252. END
  253. def constantinople_attack # Battle engine
  254. $western_reinforcements = rand(50_000..75_000)
  255. if $western_reinforcements > 60_000
  256. sleep(3)
  257. puts <<-END
  258.  
  259. Reinforcements from the West are here! They are forming up to join
  260. our attack!"
  261. END
  262. else
  263. sleep(3)
  264. puts <<-END
  265.  
  266. The West did send reinforcements. Let us hope they will be enough.
  267. END
  268. end
  269. roman_attack = rand((150_000)..($ottoman_army)) - ($eastern_roman_army + $western_reinforcements)
  270. # Calculates battle results with randomizer for strengths of opposing armies due to reinforcements
  271. # and casualties, etc., and based on theory of 3 attackers vs. 1 defender
  272. sleep(5)
  273. msg = 'BATTLE IN PROGRESS! BATTLE IN PROGRESS!'
  274.  
  275. 15.times do
  276. print "\r#{ msg }"
  277. sleep 0.5
  278. print "\r#{ ' ' * msg.size }" # Flashes what is taking place.
  279. sleep 0.5
  280. end
  281. if roman_attack > rand(90_000..110_000)
  282. sleep(3)
  283. puts <<-END
  284.  
  285. Praise God, my lord Constantine! We have defeated the Turks! They were
  286. broken on the field and are fleeing in disarray!
  287.  
  288. Our cavalry are in pursuit and a detachment is right now searching for
  289. the Sultan and members of his court.
  290.  
  291. You have delivered our city from conquest! You will be known to
  292. history forever!
  293.  
  294. GAME OVER. YOU WIN! ROMA ETERNA!
  295.  
  296. END
  297. else
  298. sleep(3)
  299. puts <<-END
  300.  
  301. DISASTER! Our army has been defeated! The Turks will surely breach our walls
  302. now and we have no more defenders left to man them!
  303.  
  304. Make haste to the harbor where a ship is waiting to take you to Italy,
  305. there to ask The Pope for help in launcing a crusade!
  306.  
  307. Go now and with God!
  308.  
  309. GAME OVER. YOU LOSE!
  310.  
  311. END
  312. end
  313. end
  314. sleep(5)
  315. constantinople_attack() # Calls on battle engine to decide outcome
  316. else
  317. sleep(3)
  318. puts <<-END
  319.  
  320. Alas! All is lost. Our citizens do not even care to fight for their city
  321. anymore! The recruitment effort has barely enrolled a thousand souls! That
  322. is not enough to hold the main square!
  323.  
  324. Cowards, all of them! What are their lives worth if instead of enlisting
  325. to defend their homes, they just wait for the Turks to come and kill
  326. them and take all they ever had?!
  327.  
  328. There is no more hope!
  329.  
  330. You, my lord, need to hurry to the harbor. There lay in anchor is a ship
  331. waiting to take you to Italy to plead for help from The Pope, that he
  332. may launch a crusade!
  333.  
  334. Go now!
  335.  
  336. GAME OVER. YOU LOSE!
  337.  
  338. END
  339. end
  340. elsif final_defense === "n"
  341. sleep(3)
  342. puts <<-END
  343.  
  344. DISASTER!!
  345.  
  346. You do not have the will to fight??
  347.  
  348. You do not deserve to wear the purple of Rome and are a disgrace
  349. to your namesake!
  350.  
  351. Reports are in that general Belisarius is sailing from Trebizond
  352. with relief and is intent on deposing you!
  353.  
  354. I would not want to be you for all the gold in the world nor
  355. here when the general arrives and annihilates the armies of Memet!
  356.  
  357. Stand aside, my lord, and I will lead our defense while we
  358. wait for relief!
  359.  
  360. Guards!
  361.  
  362. Take the Emperor to his quarters and see to it that
  363. he is not to be disturbed. Admit no one, and I mean nobody
  364. is allowed to see him - not even the Empress herself!
  365.  
  366. Go!
  367.  
  368. GAME OVER. YOU LOSE!
  369.  
  370. END
  371. end
  372. end
  373. when 'c' # Roman will conclude a treaty of friendship <-- least risky course
  374. # of action and solves the "Byzantine General's Problem"
  375. sleep(3)
  376. puts <<-END
  377.  
  378. I think for now that is the wisest course of action. For more than
  379. fifteen centuries, we Romans have been masters of our destiny.
  380. We can bear this state of affairs for now.
  381.  
  382. The Sultan is most pleased by your decision and awaits the
  383. Princess Theodora Porphyrogenita in his camp and is proud to
  384. call you brother! Let our two realms coexist peacefully
  385. side-by side for all time!
  386.  
  387. My lord, The Turks are pulling down their siege towers and
  388. are breaking camp. Well done!
  389.  
  390. History will show that you will use this time wisely to rebuild
  391. Constantinople's empire, army and morale!
  392.  
  393. GAME OVER. YOU WIN! ROMA ETERNA!
  394.  
  395. END
  396. else # Roman default
  397. sleep(3)
  398. puts <<-END
  399.  
  400. What kind of choice is that? These are desperate times, my lord.
  401.  
  402. The fate of the city rests on your decision!
  403.  
  404. It cannot survive on indecision or incompetence.
  405.  
  406. GAME OVER. YOU LOSE!
  407.  
  408. END
  409. end
  410. when 'f' # Roman has decided to fight
  411. sleep(3)
  412. puts <<-END
  413.  
  414. Very good, my lord, and we give battle at once! Sound the trumpets!
  415. We may no longer have the troops to sally forth to meet and overwhelm
  416. the enemy on the field, but we will make sure they never breach our walls!
  417.  
  418. I will see that all gates are barred shut and all towers and
  419. ramparts are manned.
  420.  
  421. We have more than enough provisions to last us years, and the
  422. West will surely send help!
  423.  
  424. They cannot afford not to! If Constantinople falls, Europe will fall!
  425.  
  426. END
  427. def constantinople_attack # Battle engine
  428. $western_reinforcements = rand(50_000..75_000)
  429. if $western_reinforcements > 60_000
  430. sleep(3)
  431. puts <<-END
  432. Large reinforcements from the West are here! They are
  433. forming up to join the attack!
  434. END
  435. else
  436. sleep(3)
  437. puts <<-END
  438.  
  439. The West did send some reinforcements. Let us hope they
  440. are enough.
  441. END
  442. end
  443. roman_attack = rand((150_000)..($ottoman_army)) - ($eastern_roman_army + $western_reinforcements)
  444. # Calculates battle results with randomizer for strengths of opposing armies due
  445. # to reinforcements and casualties, etc., and based on theory of 3 attackers vs. 1 defender
  446. sleep(5)
  447. msg = 'BATTLE IN PROGRESS! BATTLE IN PROGRESS!'
  448.  
  449. 15.times do
  450. print "\r#{ msg }"
  451. sleep 0.5
  452. print "\r#{ ' ' * msg.size }" # Flashes what is taking place.
  453. sleep 0.5
  454. end
  455. if roman_attack > rand(90_000..110_000)
  456. sleep(3)
  457. puts <<-END
  458.  
  459. Praise God, my lord Constantine! We have defeated the Turks!
  460. They were broken on the field and are fleeing in disarray!
  461.  
  462. Our cavalry are in pursuit and a squadron is right now searching
  463. for the Sultan and members of his court.
  464.  
  465. You have delivered our city from conquest! You will be be known
  466. to history forever!
  467.  
  468. GAME OVER. YOU WIN! ROMA ETERNA!
  469.  
  470. END
  471. else
  472. sleep(3)
  473. puts <<-END
  474.  
  475. DISASTER!
  476.  
  477. Our army has been defeated! The Turks will surely breach
  478. our walls now and we have no more defenders left to man them!
  479.  
  480. I pray the invaders to be merciful, though I doubt it.
  481.  
  482. Make ready to flee through the catacombs!
  483.  
  484. Go! Quickly! There is a ship by the harbor waiting to take you to Italy!
  485.  
  486. Farewell, my Emperor!
  487.  
  488. GAME OVER. YOU LOSE!
  489.  
  490. END
  491. end
  492. end
  493. sleep(5)
  494. constantinople_attack() # Calls on the attack
  495. when 's' # Roman will surrender the city
  496. sleep(3)
  497. puts <<-END
  498.  
  499. DISASTER!!
  500.  
  501. You do not have the will to fight?? You do not deserve to wear the
  502. purple of Rome and are a disgrace to your namesake!
  503.  
  504. Reports are in that general Belisarius is sailing from Trebizond
  505. with relief and is intent on deposing you!
  506.  
  507. I would not want to be you for all the gold in the world nor here
  508. when the general arrives and annihilates the armies of Memet!
  509.  
  510. Stand aside, my lord, and I will lead our defense while we wait for relief!
  511.  
  512. Guards, take the Emperor to his quarters and see to it that he is not
  513. to be disturbed. Admit no one, and I mean nobody is allowed to see him
  514. - not even the Empress herself!
  515.  
  516. Go!
  517.  
  518. GAME OVER. YOU LOSE!
  519.  
  520. END
  521. else # Roman default
  522. sleep(3)
  523. puts <<-END
  524.  
  525. What kind of choice is that? These are desperate times, my lord.
  526.  
  527. The fate of the city rests on your decision!
  528.  
  529. It cannot survive on indecision or incompetence.
  530.  
  531. GAME OVER. YOU LOSE!
  532.  
  533. END
  534. end
  535. when 'o' # Player has chosen to be Ottoman
  536. sleep(3)
  537. puts <<-END
  538.  
  539. Agha Izmir: My Sultan Memet, Sire! We are finally besieging the
  540. greatest city in the world, and God-willing, it will soon belong to you!
  541.  
  542. What would you have us do?
  543.  
  544. (E)ntreat with the Emperor Constantine and have him submit to your
  545. authority, (d)emand ranson, (a)ssault the Theodosian Walls?
  546.  
  547. END
  548. case gets.chomp.downcase
  549. when 'e' # Ottoman will entreat with Roman
  550. sleep(3)
  551. puts <<-END
  552.  
  553. Very well. Their representative, Count Nicopherus and his retinue are
  554. just outside the camp. I will tell the guards to admit them.
  555.  
  556. The Roman ambassador is here, Sire. While I do not necessarily agree
  557. with it, diplomacy seems to be the order of the day.
  558.  
  559. I know Nicopherus quite well. He and I grew up together in his father's
  560. estate near Adrianople when I was a hostage for my own father's
  561. good behavior. I was well-treated and released after academy training
  562. years later.
  563.  
  564. One can say I learned statecraft at his father's knee.
  565.  
  566. It is quite ironic to meet him again after all this time in vastly
  567. different circumstances.
  568.  
  569. While crafty and shrewd, he is also very honorable.
  570.  
  571. I just pray the Romans have the good sense to accept our offer
  572. - that we will withdraw from their former European territories if
  573. they promise to abandon Asia Minor and Africa province.
  574.  
  575. Do we begin? (Y)es or (n)o?
  576.  
  577. END
  578. case gets.chomp.downcase
  579. when 'y'
  580. never_on_tuesday = Time.now.strftime("%A") # Constantinople was conquered
  581. # on a Tuesday and is the unluckiest day of the week in that part of the world
  582. if never_on_tuesday === "Tuesday"
  583. charm = 0
  584. else charm = rand(0..50)
  585. end
  586. roman_pride = rand(0..51) # When charm is 0, it becomes necessary to give Rome, i.e.
  587. # if you play this game on a Tuesday, the engine gives an already disadvantaged
  588. # side a one percent delta to effect a win
  589. sleep(5)
  590. msg = 'NEGOTIATIONS IN PROGRESS! NEGOTIATIONS IN PROGRESS!'
  591.  
  592. 15.times do
  593. print "\r#{ msg }"
  594. sleep 0.5
  595. print "\r#{ ' ' * msg.size }" # Flashes what is taking place.
  596. sleep 0.5
  597. end
  598. negotiation_proper = charm + roman_pride
  599. if negotiation_proper > rand(45..55)
  600. sleep(3)
  601. puts <<-END
  602.  
  603. Sultan!
  604.  
  605. They have agreed to everything we proposed!
  606.  
  607. We will hand over territory up to the Danube in the north, where the Bulgars
  608. are, and near the Italian border to the west, and then the Euxine Sea
  609. in the east.
  610.  
  611. We will also guarantee their sovereignty over the Hellespont
  612. and the Bosporus. Leave it in their hands to deny them to Western armies
  613. on their way east!
  614.  
  615. In return, they on the other hand relinquish claim and
  616. control over Anatolia, Palestina, Aegyptus, and Africa.
  617.  
  618. Congratulations!
  619.  
  620. GAME OVER. YOU WIN!
  621.  
  622. END
  623. else
  624. sleep(3)
  625. puts <<-END
  626.  
  627. They said "NO" to everything! It beggars belief!
  628.  
  629. That is not my friend, Nicopherus' logic. It must be Constantine's!
  630.  
  631. Why in God's name refuse such a generous offer?
  632.  
  633. Constantinople is not what it once was! There are no more Augustii
  634. on the throne!
  635.  
  636. The last of the true Romans died with Justinian nearly a thousand years ago!
  637.  
  638. I should have guessed this was a waste of time!
  639.  
  640. It is a pity Nicopherus allowed himself to be used by Constantine this way.
  641. I knew this was nothing but a delaying tactic on their part.
  642.  
  643. Guards!
  644.  
  645. Escort my dear friend the Count, but the hold members of his retinue and
  646. behead them. That will teach them to play games when their very
  647. survival is at stake!
  648.  
  649. We must attack at once!
  650.  
  651. END
  652. def ottoman_attack # Battle engine
  653. $western_reinforcements = rand(50_000..75_000)
  654. if $western_reinforcements > 60_000
  655. sleep(3)
  656. puts <<-END
  657.  
  658. Sire! Scouts bring word that reinforcements from Europe have just landed.
  659. They are bolstering city defenses as we speak!
  660.  
  661. END
  662. else
  663. sleep(3)
  664. puts <<-END
  665.  
  666. It seems as if reinforcements from the West have arrived, but reports
  667. indicate their numbers are not what Constantine had been promised. Ha!
  668.  
  669. END
  670. end
  671. ottoman_army_attack = rand((150_000)..($ottoman_army)) - ($eastern_roman_army + $western_reinforcements)
  672. # Calculates battle results with randomizer for strengths of opposing armies due to reinforcements
  673. # and casualties, etc., and based on theory of 3 attackers vs. 1 defender
  674. sleep(5)
  675. msg = 'BATTLE IN PROGRESS! BATTLE IN PROGRESS!'
  676.  
  677. 10.times do
  678. print "\r#{ msg }"
  679. sleep 0.5
  680. print "\r#{ ' ' * msg.size }" # Flashes what is taking place.
  681. sleep 0.5
  682. end
  683. if ottoman_army_attack > rand(90_000..110_000)
  684. sleep(3)
  685. puts <<-END
  686.  
  687. Praise God, Sultan! We have taken the city! The remnants of
  688. heir army are fleeing through their tunnels.
  689.  
  690. Janissaries are attempting to storm the Imperial Palace,
  691. and we should eliminate all further resistance in a day or two.
  692.  
  693. Then, we can let the customary three-day looting begin!
  694.  
  695. Congratulations, Memet II, Conqueror of The Roman Empire!
  696.  
  697. GAME OVER. YOU WIN!
  698.  
  699. END
  700. else
  701. sleep(3)
  702. puts <<-END
  703.  
  704. DISASTER!
  705.  
  706. Our assault has been has been repelled! It must surely
  707. be those reinforcements.
  708.  
  709. Curse the Romans! We should order all surviving troops
  710. to regroup and withdraw to safety in the west. We still have sizeable
  711. formations encamped there to dissuade Constantine from ordering
  712. a counterattack!
  713.  
  714. We will bring down this city once and for all, but perhaps now is
  715. not yet the time.
  716.  
  717. GAME OVER. YOU LOSE!
  718.  
  719. END
  720. end
  721. end
  722. sleep(5)
  723. ottoman_attack()
  724. end
  725. when 'n'
  726. sleep(3)
  727. puts <<-END
  728.  
  729. Sultan, we must not resort to tricks and should show to be more honorable
  730. than these infidels.
  731.  
  732. If you do not have any intentions of negotiating with their representatives,
  733. let us release them and begin our assault at once!
  734.  
  735. Should we attack now? (Y)
  736.  
  737. END
  738. case gets.chomp.downcase
  739. when 'y'
  740. sleep(3)
  741. puts <<-END
  742.  
  743. Excellent. Count Nicopherus and his party have left and orders are
  744. now going out to our commanders.
  745.  
  746. The assault should commence at any moment.
  747.  
  748. END
  749. def ottoman_attack # Battle engine
  750. $western_reinforcements = rand(50_000..75_000)
  751. if $western_reinforcements > 60_000
  752. sleep(3)
  753. puts <<-END
  754.  
  755. Sire! Scouts bring word that reinforcements from Europe have just landed.
  756. They are bolstering city defenses as we speak!"
  757. END
  758. else
  759. sleep(3)
  760. puts <<-END
  761.  
  762. It seems as if reinforcements from the West have arrived, but reports
  763. indicate their numbers are not what Constantine had been promised. Ha!"
  764. END
  765. end
  766. ottoman_army_attack = rand((150_000)..($ottoman_army)) - ($eastern_roman_army + $western_reinforcements)
  767. # Calculates battle results with randomizer for strengths of opposing armies due to reinforcements
  768. # and casualties, etc., and based on theory of 3 attackers vs. 1 defender
  769. sleep(5)
  770. msg = 'BATTLE IN PROGRESS! BATTLE IN PROGRESS!'
  771.  
  772. 15.times do
  773. print "\r#{ msg }"
  774. sleep 0.5
  775. print "\r#{ ' ' * msg.size }" # Flashes what is taking place.
  776. sleep 0.5
  777. end
  778. if ottoman_army_attack > rand(90_000..110_000)
  779. sleep(3)
  780. puts <<-END
  781.  
  782. Praise God, Sultan! We have taken the city! The remnants of
  783. their army are fleeing through their tunnels.
  784.  
  785. Janissaries are attempting to storm the Imperial Palace,
  786. and we should eliminate all further resistance in a day or two.
  787.  
  788. Then, we can let the customary three-day looting begin!
  789.  
  790. Congratulations, Memet II, Conqueror of The Roman Empire!
  791.  
  792. GAME OVER. YOU WIN!
  793.  
  794. END
  795. else
  796. sleep(3)
  797. puts <<-END
  798.  
  799. DISASTER!
  800.  
  801. Our assault has been has been repelled! It must surely be
  802. those reinforcements.
  803.  
  804. Curse the Romans! We should order all surviving troops to regroup
  805. and withdraw to safety in the west. We still have sizeable formations
  806. there to dissuade Constantine from any notion of a counterattack.
  807.  
  808. We will bring down this city once and for all, but perhaps
  809. now is not yet the time.
  810.  
  811. GAME OVER. YOU LOSE!
  812.  
  813. END
  814. end
  815. end
  816. sleep(5)
  817. ottoman_attack()
  818. else
  819. end
  820. end
  821. when 'd' # Ottoman will demand ransom
  822. sleep(3)
  823. puts <<-END
  824.  
  825. Tell his Imperial Majesty, that the price of peace is we will accept no less
  826. than 1,000,000 lbs. of minted bullion, and he has a fortnight to reply.
  827.  
  828. Let us await what they say.
  829.  
  830. END
  831. roman_gold = rand(500_000..1_500_000) # Generate random amount Romans
  832. # are willing to pay after demand is made
  833. sleep(5)
  834.  
  835. puts "Sultan, the Romans have sent" + " #{roman_gold} " + "pounds."
  836. if roman_gold < 1_000_000
  837. sleep(5)
  838. puts <<-END
  839.  
  840. Those misers! They insult us not with that amount but with their
  841. arrogance to offer it. We attack at once!
  842.  
  843. Do we deploy artillery, Sire? (Y)es or (n)o?
  844.  
  845. END
  846. deploy_cannon = gets.chomp.downcase
  847. if deploy_cannon === "y"
  848. sleep(3)
  849. puts <<-END
  850.  
  851. Yes! Move the cannon into position and shoot at will!
  852.  
  853. Let us see if that bronze is worth its weight in gold!
  854.  
  855. We paid a small fortune for them and they had better work.
  856.  
  857. END
  858. sleep(5)
  859. msg = 'BATTLE IN PROGRESS! BATTLE IN PROGRESS!'
  860.  
  861. 15.times do
  862. print "\r#{ msg }"
  863. sleep 0.5
  864. print "\r#{ ' ' * msg.size }" # Flashes what is taking place.
  865. sleep 0.5
  866. end
  867. cannon_shot = rand(1..10_000) # Attempts to break down walls
  868. $wall_damage = $theodosian_walls - cannon_shot - ($luck_factor * cannon_shot)
  869. if $wall_damage > 10_000
  870. sleep(3)
  871. puts <<-END
  872.  
  873. Praise God, Sultan! A huge section has collapsed and the breach
  874. is wide enough for hundreds of our troops to pour through
  875. at once!
  876.  
  877. We have taken the city! The remnants of their army are fleeing
  878. through their tunnels.
  879.  
  880. That Viennese cannon-maker has delivered. We must have him forge
  881. us some more.
  882.  
  883. Janissaries are attempting to storm the Imperial Palace,
  884. and we should eliminate all further resistance in a day or two.
  885.  
  886. Then, we can let the customary three-day looting begin!
  887.  
  888. Congratulations, Memet II, Conqueror of The Roman Empire!
  889.  
  890. GAME OVER. YOU WIN!
  891.  
  892. END
  893. else
  894. sleep(3)
  895. puts <<-END
  896.  
  897. These cannon are useless! Get the sappers!
  898.  
  899. Yes, Sire. Tunneling has commenced! Theodosius' walls are
  900. not just stout, they are deep, and it will take time to burrow
  901. underneath them and make sure we have packed enough powder to
  902. bring down a section.
  903.  
  904. END
  905. sleep(5)
  906. msg = 'BATTLE IN PROGRESS! BATTLE IN PROGRESS!'
  907.  
  908. 10.times do
  909. print "\r#{ msg }"
  910. sleep 0.5
  911. print "\r#{ ' ' * msg.size }" # Flashes what is taking place.
  912. sleep 0.5
  913. end
  914. sappers_progress = rand(1..6_500) # Attempts to break down walls with
  915. # different chance percentage because sappers are inherently a weaker value attack than artillery
  916. wall_damage_sappers = $theodosian_walls - sappers_progress - ($luck_factor * sappers_progress)
  917. if wall_damage_sappers > 7_500
  918. sleep(3)
  919. puts <<-END
  920.  
  921. Praise God, Sultan! The sappers have managed to
  922. undermine and bring down a large section of walls in
  923. a lightly-defended area!
  924.  
  925. The breach is large enough that hundreds of our troops
  926. can pour through at once!
  927.  
  928. We have taken the city! The remnants of their army are fleeing
  929. through their tunnels.
  930.  
  931. Janissaries are attempting to storm the Imperial Palace, and
  932. we should eliminate all further resistance in a day or two.
  933.  
  934. Then, we can let the customary three-day looting begin!
  935.  
  936. Congratulations, Memet II, Conqueror of The Roman Empire!
  937.  
  938. GAME OVER. YOU WIN!
  939.  
  940. END
  941. else
  942. sleep(3)
  943. puts <<-END
  944.  
  945. DISASTER!
  946.  
  947. Our assault has been has been repelled! How could this be?
  948.  
  949. Curse the Romans! We should order all surviving troops to
  950. regroup and withdraw to safety in the south. I have placed sizeable
  951. formations there to guard against any landings from Europe, and joining
  952. what strength we still have will dissuade Constantine from ordering
  953. a counterattack.
  954.  
  955. We will bring down this city once and for all, but perhaps
  956. now is not yet the time.
  957.  
  958. And behead that useless Viennese cannon-maker when you
  959. find him!
  960.  
  961. GAME OVER. YOU LOSE!
  962.  
  963. END
  964. end
  965. end
  966. elsif deploy_cannon === "n"
  967. sleep(3)
  968. puts <<-END
  969.  
  970. Very well. Siege towers are on their way! We have more than two score
  971. and the Romans simply don't have enough men to bring them all down!
  972.  
  973. Come to the pavillion and let us observe!
  974.  
  975. END
  976. sleep(5)
  977. msg = 'BATTLE IN PROGRESS! BATTLE IN PROGRESS!'
  978.  
  979. 10.times do
  980. print "\r#{ msg }"
  981. sleep 0.5
  982. print "\r#{ ' ' * msg.size }" # Flashes what is taking place.
  983. sleep 0.5
  984. end
  985. siege_towers = rand(1..8_500) # Attempts to bring down walls with different
  986. # chance percentage - attack value is near median between artillery & sappers
  987. wall_damage_siege = $theodosian_walls - siege_towers - ($luck_factor * siege_towers)
  988. if wall_damage_siege > 7_500
  989. sleep(3)
  990. puts <<-END
  991.  
  992. Praise God, Sultan! Our men are over the walls!
  993.  
  994. As I predicted, hey did not have enough to bring down many of our towers
  995. and their defenders have been displaced near the gates where they where
  996. strongest!
  997.  
  998. We have taken the city! The remnants of their army are fleeing
  999. through the tunnels.
  1000.  
  1001. Janissaries are attempting to storm the Imperial Palace, and
  1002. we should eliminate all further resistance in a day or two.
  1003.  
  1004. Then, we can let the customary three-day looting begin!
  1005.  
  1006. Congratulations, Memet II, Conqueror of The Roman Empire!
  1007.  
  1008. GAME OVER. YOU WIN!
  1009.  
  1010. END
  1011. else
  1012. sleep(3)
  1013. puts <<-END
  1014.  
  1015. DISASTER!
  1016.  
  1017. Our assault has been has been repelled! How could this be?
  1018.  
  1019. Curse the Romans! We should order all surviving troops to
  1020. regroup and withdraw to safety in the north. We still have sizeable
  1021. formations there to dissuade Constantine from ordering a counterattack.
  1022.  
  1023. The Bulgars will welcome us. There is no love lost between them and
  1024. the Romans.
  1025.  
  1026. We will bring down this city once and for all, but perhaps
  1027. now is not yet the time.
  1028.  
  1029. GAME OVER. YOU LOSE!
  1030.  
  1031. END
  1032. end
  1033. end
  1034. else
  1035. sleep(3)
  1036. puts <<-END
  1037.  
  1038. Ah! He is wise, that Constantine, much like his ancestors.
  1039.  
  1040. He must have sent us the entire contents of his treasury.
  1041. What will he have now to rebuild?!
  1042.  
  1043. In the meantime, we will use that gold to expand our fleet and block off
  1044. the city's access to the sea. Give them their relief for ten years
  1045. and we will come back.
  1046.  
  1047. Put out the word to lift the siege and break camp at once!
  1048.  
  1049. God be praised that no one must perish today.
  1050.  
  1051. And send my brother, the Emperor Constantine, a nice gift of thanks.
  1052.  
  1053. GAME OVER. YOU WIN!
  1054.  
  1055. END
  1056. end
  1057. when 'a' # Ottoman will order an assault
  1058. sleep(3)
  1059. puts <<-END
  1060.  
  1061. God be praised! Our troops have been waiting for this day for so long!
  1062. We have come so far and very soon, the greatest city in the world
  1063. shall be ours!
  1064.  
  1065. We go at once!
  1066.  
  1067. Signal all commands to make ready their assault according to plan!
  1068.  
  1069. END
  1070. def ottoman_attack # Battle engine
  1071. $western_reinforcements = rand(50_000..75_000)
  1072. if $western_reinforcements > 60_000
  1073. sleep(3)
  1074. puts <<-END
  1075.  
  1076. Sire! Scouts bring word that reinforcements from Europe have just landed.
  1077. They are bolstering city defenses as we speak!
  1078.  
  1079. END
  1080. else
  1081. sleep(3)
  1082. puts <<-END
  1083. It seems as if reinforcements from the West have arrived, but reports
  1084. indicate their numbers are not what Constantine had been promised. Ha!
  1085.  
  1086. END
  1087. end
  1088. ottoman_army_attack = rand((150_000)..($ottoman_army)) - ($eastern_roman_army + $western_reinforcements)
  1089. # Calculates battle results with randomizer for strengths of opposing armies due to
  1090. # reinforcements and casualties, etc., and based on theory of 3 attackers vs. 1 defender
  1091. sleep(5)
  1092. msg = 'BATTLE IN PROGRESS! BATTLE IN PROGRESS!'
  1093.  
  1094. 15.times do
  1095. print "\r#{ msg }"
  1096. sleep 0.5
  1097. print "\r#{ ' ' * msg.size }" # Flashes what is taking place.
  1098. sleep 0.5
  1099. end
  1100. if ottoman_army_attack > rand(90_000..100_000)
  1101. sleep(3)
  1102. puts <<-END
  1103.  
  1104. Praise God, Sultan! We have taken the city! The remnants of their
  1105. army are fleeing through their tunnels.
  1106.  
  1107. Janissaries are attempting to storm the Imperial Palace, and
  1108. we should eliminate all further resistance in a day or two.
  1109.  
  1110. Then, we can let the customary three-day looting begin!
  1111.  
  1112. Congratulations, Memet II, Conqueror of The Roman Empire!
  1113.  
  1114. GAME OVER. YOU WIN!
  1115.  
  1116. END
  1117. else
  1118. sleep(3)
  1119. puts <<-END
  1120.  
  1121. DISASTER!
  1122.  
  1123. Our assault has been has been repelled! It must surely be those
  1124. reinforcements.
  1125.  
  1126. Curse the Romans! We should order all surviving troops to regroup
  1127. and withdraw to safety in the west. We still have sizeable formations
  1128. there to dissuade Constantine from ordering a counterattack.
  1129.  
  1130. We will bring down this city once and for all, but perhaps
  1131. now is not yet the time.
  1132.  
  1133. GAME OVER. YOU LOSE!
  1134.  
  1135. END
  1136. end
  1137. end
  1138. sleep(5)
  1139. ottoman_attack() # Calls on battle engine
  1140. else # Ottoman default
  1141. sleep(3)
  1142. puts <<-END
  1143.  
  1144. Sire, I do not understand your command. There is not a moment to lose.
  1145. We have the greatest prize in the world right before us.
  1146.  
  1147. GAME OVER. YOU LOSE!
  1148.  
  1149. END
  1150. end
  1151. else # Player default
  1152. sleep(3)
  1153. puts <<-END
  1154.  
  1155. Invalid choice. Again, please.
  1156.  
  1157. END
  1158. game_play # Loops to beginning of game
  1159. end
  1160. end
  1161. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement