Class: YumemoireZombieMode::ZombieMode

Inherits:
Object
  • Object
show all
Defined in:
lib/YumemoireFramework.rb

Class Method Summary collapse

Class Method Details

.ai_decisionObject

AI Decision Making #



1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
# File 'lib/YumemoireFramework.rb', line 1704

def self.ai_decision
  cchoice = @choice

  ## Determining user data and user choice.
  value = File.read("lib/input/user/user_choice.txt").to_s.to_i

  user_data   = File.readlines("lib/data/user/candidates.txt")
  user_choice = user_data[value]

  ## Processing AI focused data
  ai_choice            = File.read("lib/data/ai/ai_choice.txt").to_s.to_i
  ai_initial_candidate = user_data[ai_choice]
  ai_search_limit      = user_data.size.to_i

  ## Create AI data from user data.
  ai_search_limit.times do
    if ai_choice == user_choice
      #puts "\e[38;2;187;127;118m  The specific candidate was found. Terminating selection..."

      ai_data      = user_data.slice!(ai_choice)

      open("lib/data/ai/candidates.txt", "w") { |f|
        f.puts ai_data
      }
    else
      puts "\e[38;2;187;127;118mL'ennemi découvre que vous n'avez pas fait ce choix...\e[0m"
    end

    sleep(1.5)
  end

  ## AI processing data.
  ai_choice            = File.read("lib/data/ai/ai_choice.txt").to_s.to_i
  ai_data              = File.readlines("lib/data/ai/candidates.txt")
  ai_search_limit      = ai_data.size.to_i
  ai_next_candidate    = ai_data[ai_choice]

  ai_search_limit.times do
    if ai_next_candidate == user_choice
      ai_final_candidate = ai_next_candidate

      puts "\e[38;2;187;127;118mCandidate found, processing input...\e[0m"; sleep(1)

      # Breaks the loop if an appropriate candidate is found.

      sleep(1.5)

      conditions = ["Sword", "Stone", "Tarp"]

      decision_made = conditions.sample

      puts "\e[38;2;187;127;118mBy process of elimination, the bot chose: #{ai_data}\e[0m"

      @cchoice = "#{ai_data}"

      puts $cchoice

      break
    else
      ai_choice            = File.read("lib/data/ai/ai_choice.txt").to_s.to_i
      ai_data              = File.readlines("lib/data/ai/candidates.txt")
      ai_search_limit      = ai_data.size.to_i
      ai_next_candidate    = ai_data[ai_choice]

      ai_data      = user_data.slice!(ai_choice).strip

      puts "\e[38;2;187;127;118mEnemy found the option #{ai_data}\e[0m"

      enemy_decision = ["choose", "skip"]

      decision_made = enemy_decision.sample

      if decision_made == "choose"
        puts "\e[38;2;187;127;118mThe enemy chose: #{ai_data}, but found it causes a stalemate. Makes a new decision\e[0m"

        @cchoice = "#{ai_data}"

        enemy_decision = ["Epee", "Ishi", "Bache"]

        decision_made = enemy_decision.sample

        if    decision_made == "Sword"
          @cchoice = "Epee"
        elsif decision_made == "Stone"
          @cchoice = "Ishi"
        elsif decision_made ==  "Tarp"
          @cchoice = "Bache"
        end

        break
      else
        puts "\e[38;2;187;127;118mEnemy weighed the option of choosing #{ai_data}, but decided to skip its turn.\e[0m"

        break
      end

      sleep(1.5)
 
      open("lib/data/ai/candidates.txt", "w") { |f|
        f.puts ai_data
      }
    end
  end

  def self.parser
    loop do
      system("clear")

      if $current_day < $lunar_ticks
        this_day = 29

        puts "\e[38;2;187;127;118mLa prochaine phase lunaire est en cours: #{this_day - $current_day} days...\e[0m"
      else
        lunar_cycle

        # Reset lunar ticks to twenty days away.
        $current_day = 1
      end

      puts "\e[38;2;187;127;118m[ Currency is #{$player_franc} Francs And #{$player_yen} Yen ]\e[0m"

      puts "\e[38;2;187;127;118m\n[ Stalemates: #{$stalemates} ] [ Player Strikes: #{$player_struck} ] [ Enemy Strikes: #{$enemy_struck} ]\e[0m"
      puts "\e[38;2;187;127;118m  [ #{$player_lunario} Lunario ( You wont need this for most game functions. ) ]"

      puts "\e[38;2;187;127;118m\n\e[0m"
      puts "\e[38;2;187;127;118mSouer De Chaos ( Ana Nuveyatusuki ) HP: #{$player_hp} \e[0m"
      puts "\e[38;2;187;127;118mSouer De Commande ( Ana Nuveyatusuki ) HP: #{$enemy_hp}\e[0m"
      puts "\e[38;2;187;127;118m\n\e[0m"

      if $player_hp > 0
        system("clear")

        puts "\e[38;2;187;127;118mYou've been zombiefied!\e[0m"

        sleep(1.5)

        system("ruby rockpaper.rb")
      elsif $enemy_hp <= 0
        puts "\e[38;2;187;127;118mYou won\e[0m"

        gets.chomp

        abort
      end

      conditions = {
        "Epee"  =>  "Ishi",
        "Ishi"  => "Bache",
        "Bache" =>  "Epee",
      }

      puts "\e[38;2;187;127;118mTo heal the player, type: Chomp\e[0m"

      print "\e[38;2;164;145;91m\nEpee, Ishi, or Bache >> \e[0m"
      @choice = gets.chomp.capitalize

      if    @choice == "Epee"
        open("lib/input/user/user_choice.txt", "w") { |f|
          f.puts "0"
        }
      elsif @choice == "Ishi"
        open("lib/input/user/user_choice.txt", "w") { |f|
          f.puts "1"
        }
      elsif @choice == "Bache"
        open("lib/input/user/user_choice.txt", "w") { |f|
          f.puts "2"
        }
      elsif @choice == "Chomp"
        open("lib/input/user/user_choice.txt", "w") { |f|
          f.puts "2"
        }
      end

      puts " "
      sleep(1.5)

      # Experiment with using an enemy that learns from player's decisions.'
      YumemoireFramework::ZombieMode.ai_decision

      if conditions[@choice] == @cchoice
        #puts "\e[38;2;187;127;118m  You were struck by the enemy!"

        $enemy_struck = $enemy_struck + 1

        # The amount of damage player gets is based on the enemies attack power.
        #$player_hp = $player_hp - $enemy_atk
        YumemoireFramework::DamageFormulas.enemy_damage_rate
      elsif @cchoice == @choice
        puts "\e[38;2;187;127;118mYou reach a stalemate.\e[0m"

        $stalemates = $stalemates + 1
      elsif conditions[@cchoice] == @choice
        #puts "\e[38;2;187;127;118m  You struck the enemy!"

        $player_struck = $player_struck + 1

        # The amount of damage enemy recieves is based on the player's attack power.
        #$enemy_hp = $enemy_hp - $player_atk
        YumemoireFramework::DamageFormulas.player_damage_rate
      elsif @choice == "Chomp"
        puts "\e[38;2;187;127;118mYou tried staying at an inn, but hotels don't take the undead...'\e[0m"

        sleep(1.5)

        YumemoireFramework::ZombieMode.consumption
      else
        puts "\e[38;2;187;127;118m#{@choice} is not a valid option\e[0m"
      end

      $current_day = $current_day + 1
    end
  end
end

.consumptionObject



1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
# File 'lib/YumemoireFramework.rb', line 1946

def self.consumption
  puts "You've eaten parts of your own corpse."

  sleep(1.5)

  $reset_hp  = $reset_hp - 1
  $player_hp = $reset_hp

  print "Your HP was replinished but "

  puts " you lost 3 hit points from consuming your own body."

  File.open("lib/player_stats/zombie_player_hp.txt", "w") { |f|
    $player_hp = $player_hp + 3

    f.puts $player_hp -20
  }

  File.open("lib/player_stats/reset_hp.txt", "w") { |f|
    $reset_hp = $reset_hp - 3

    f.puts $reset_hp
  }

  system("ruby rock_paper_zombie.rb")
end

.cremationObject



1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
# File 'lib/YumemoireFramework.rb', line 1932

def self.cremation
  puts "You've self cremated."

  sleep(1.5)

  puts "You've opted to self cremate. Restarting the map."

  $player_hp = $reset_hp

  puts "Now returning to human form..."

  system("ruby rockpaper.rb")
end

.final_wishesObject



1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
# File 'lib/YumemoireFramework.rb', line 1973

def self.final_wishes
  print "Do you wish to self-cremate or continue this battle? ( cremate / consumption ) << "

  choose_your_fate = gets.chomp

  if    choose_your_fate == "cremate"
    YumemoreFramework::ZombieMode.cremation
  elsif choose_your_fate == "consumption"
    YumemoreFramework::ZombieMode.consumption
  else
    puts ">> Last wishes not understoood, defaulting to self-cremation."
  end
end

.parserObject



1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
# File 'lib/YumemoireFramework.rb', line 1808

def self.parser
  loop do
    system("clear")

    if $current_day < $lunar_ticks
      this_day = 29

      puts "\e[38;2;187;127;118mLa prochaine phase lunaire est en cours: #{this_day - $current_day} days...\e[0m"
    else
      lunar_cycle

      # Reset lunar ticks to twenty days away.
      $current_day = 1
    end

    puts "\e[38;2;187;127;118m[ Currency is #{$player_franc} Francs And #{$player_yen} Yen ]\e[0m"

    puts "\e[38;2;187;127;118m\n[ Stalemates: #{$stalemates} ] [ Player Strikes: #{$player_struck} ] [ Enemy Strikes: #{$enemy_struck} ]\e[0m"
    puts "\e[38;2;187;127;118m  [ #{$player_lunario} Lunario ( You wont need this for most game functions. ) ]"

    puts "\e[38;2;187;127;118m\n\e[0m"
    puts "\e[38;2;187;127;118mSouer De Chaos ( Ana Nuveyatusuki ) HP: #{$player_hp} \e[0m"
    puts "\e[38;2;187;127;118mSouer De Commande ( Ana Nuveyatusuki ) HP: #{$enemy_hp}\e[0m"
    puts "\e[38;2;187;127;118m\n\e[0m"

    if $player_hp > 0
      system("clear")

      puts "\e[38;2;187;127;118mYou've been zombiefied!\e[0m"

      sleep(1.5)

      system("ruby rockpaper.rb")
    elsif $enemy_hp <= 0
      puts "\e[38;2;187;127;118mYou won\e[0m"

      gets.chomp

      abort
    end

    conditions = {
      "Epee"  =>  "Ishi",
      "Ishi"  => "Bache",
      "Bache" =>  "Epee",
    }

    puts "\e[38;2;187;127;118mTo heal the player, type: Chomp\e[0m"

    print "\e[38;2;164;145;91m\nEpee, Ishi, or Bache >> \e[0m"
    @choice = gets.chomp.capitalize

    if    @choice == "Epee"
      open("lib/input/user/user_choice.txt", "w") { |f|
        f.puts "0"
      }
    elsif @choice == "Ishi"
      open("lib/input/user/user_choice.txt", "w") { |f|
        f.puts "1"
      }
    elsif @choice == "Bache"
      open("lib/input/user/user_choice.txt", "w") { |f|
        f.puts "2"
      }
    elsif @choice == "Chomp"
      open("lib/input/user/user_choice.txt", "w") { |f|
        f.puts "2"
      }
    end

    puts " "
    sleep(1.5)

    # Experiment with using an enemy that learns from player's decisions.'
    YumemoireFramework::ZombieMode.ai_decision

    if conditions[@choice] == @cchoice
      #puts "\e[38;2;187;127;118m  You were struck by the enemy!"

      $enemy_struck = $enemy_struck + 1

      # The amount of damage player gets is based on the enemies attack power.
      #$player_hp = $player_hp - $enemy_atk
      YumemoireFramework::DamageFormulas.enemy_damage_rate
    elsif @cchoice == @choice
      puts "\e[38;2;187;127;118mYou reach a stalemate.\e[0m"

      $stalemates = $stalemates + 1
    elsif conditions[@cchoice] == @choice
      #puts "\e[38;2;187;127;118m  You struck the enemy!"

      $player_struck = $player_struck + 1

      # The amount of damage enemy recieves is based on the player's attack power.
      #$enemy_hp = $enemy_hp - $player_atk
      YumemoireFramework::DamageFormulas.player_damage_rate
    elsif @choice == "Chomp"
      puts "\e[38;2;187;127;118mYou tried staying at an inn, but hotels don't take the undead...'\e[0m"

      sleep(1.5)

      YumemoireFramework::ZombieMode.consumption
    else
      puts "\e[38;2;187;127;118m#{@choice} is not a valid option\e[0m"
    end

    $current_day = $current_day + 1
  end
end

.reset_standard_hp_restorationObject



1926
1927
1928
1929
1930
# File 'lib/YumemoireFramework.rb', line 1926

def self.reset_standard_hp_restoration
  puts "The curse of being a zombie has been lifted. You can not die like any other mortal."

  $reset_hp = $true_reset_hp
end