--__________         __    __  .__           ___________
--\______   \_____ _/  |__/  |_|  |   ____   \_   _____/__________
-- |    |  _/\__  \\   __\   __\  | _/ __ \   |    __)/  _ \_  __ \
-- |    |   \ / __ \|  |  |  | |  |_\  ___/   |     \(  <_> )  | \/
-- |______  /(____  /__|  |__| |____/\___  >  \___  / \____/|__|
--        \/      \/                     \/       \/
--   _____                     .___.__
--  /     \ _____    ____    __| _/|__| ____  ___________
-- /  \ /  \\__  \  /    \  / __ | |  |/ ___\/  _ \_  __ \
--/    Y    \/ __ \|   |  \/ /_/ | |  \  \__(  <_> )  | \/
--\____|__  (____  /___|  /\____ | |__|\___  >____/|__|
--        \/     \/     \/      \/         \/

--      cheats.lua - Cheat codes
--
--      (c) Copyright 2005 by Kimmo Merikivi
--
--      This program is free software; you can redistribute it and/or modify
--      it under the terms of the GNU General Public License as published by
--      the Free Software Foundation; either version 2 of the License, or
--      (at your option) any later version.
--
--      This program is distributed in the hope that it will be useful,
--      but WITHOUT ANY WARRANTY; without even the implied warranty of
--      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--      GNU General Public License for more details.
--  
--      You should have received a copy of the GNU General Public License
--      along with this program; if not, write to the Free Software
--      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------

speedcheat = false
godcheat = false

function HandleCheats(str)
  local resources = { "gold", "wood", "oil", "iron", "stone", "titanium" }

  if (str == "I am the richest!") then
    SetPlayerResource(GetThisPlayer(), "gold",
      GetPlayerResource(GetThisPlayer(), "gold") + 120000)
    SetPlayerResource(GetThisPlayer(), "wood",
      GetPlayerResource(GetThisPlayer(), "wood") + 50000)
    SetPlayerResource(GetThisPlayer(), "oil",
      GetPlayerResource(GetThisPlayer(), "oil") + 50000)
    AddMessage("Aargh! Who took my money?")

  elseif (str == "Send scouts!") then
    RevealMap()

  elseif (str == "You are fool, fog!") then
    SetFogOfWar(false)
    
  elseif (str == "Make it faster!") then
    for i = 1,table.getn(resources) do
      SetSpeedResourcesHarvest(resources[i], 10)
      SetSpeedResourcesReturn(resources[i], 10)
    end
    SetSpeedBuild(10)
    SetSpeedTrain(10)
    SetSpeedUpgrade(10)
    SetSpeedResearch(10)
    AddMessage("FAST SPEED")

  elseif (str == "Normal speed.") then
    for i = 1,table.getn(resources) do
      SetSpeedResourcesHarvest(resources[i], 1)
      SetSpeedResourcesReturn(resources[i], 1)
    end
    SetSpeedBuild(1)
    SetSpeedTrain(1)
    SetSpeedUpgrade(1)
    SetSpeedResearch(1)
    AddMessage("NORMAL SPEED")

  elseif (str == "I want to be a winner!") then
    if (speedcheat) then
      speedcheat = false
      for i = 1,table.getn(resources) do
        SetSpeedResourcesHarvest(resources[i], 1)
        SetSpeedResourcesReturn(resources[i], 1)
      end
      SetSpeedBuild(1)
      SetSpeedTrain(1)
      SetSpeedUpgrade(1)
      SetSpeedResearch(1)
      AddMessage("You will lose!")
    else
      speedcheat = true
      for i = 1,table.getn(resources) do
        SetSpeedResourcesHarvest(resources[i], 10)
        SetSpeedResourcesReturn(resources[i], 10)
      end
      SetSpeedBuild(10)
      SetSpeedTrain(10)
      SetSpeedUpgrade(10)
      SetSpeedResearch(10)
      for i = 1,table.getn(resources) do
        SetPlayerResource(GetThisPlayer(), resources[i],
          GetPlayerResource(GetThisPlayer(), resources[i]) + 320000)
      end
      AddMessage("You will win!")
    end

  elseif (str == "Send forth all legions.") then
    ActionVictory()

  elseif (str == "No! You cannot do that!") then
    ActionDefeat()

  elseif (str == "No man can kill us. Die now.") then
    if (godcheat) then
      godcheat = false
      SetGodMode(false)
      AddMessage("I feel I am weak.")
    else
      godcheat = true
      SetGodMode(true)
      AddMessage("We will kill all in our path.")
      
    end

  elseif (str == "I need mana!") then
    t = GetUnits("this");
    for i = 1,table.getn(t) do
      SetUnitMana(t[i], 1000)
    end
    
  elseif (str == "Robin Wood") then
    SetPlayerResource(GetThisPlayer(), "wood",
      GetPlayerResource(GetThisPlayer(), "wood") + 5000)
    AddMessage("And here he comes!")

  elseif (str == "I'm sitting on a gold mine!!") then
    SetPlayerResource(GetThisPlayer(), "gold",
      GetPlayerResource(GetThisPlayer(), "gold") + 5000)
    AddMessage("Oh are you?")

  elseif (str == "Black rain") then
    SetPlayerResource(GetThisPlayer(), "oil",
      GetPlayerResource(GetThisPlayer(), "oil") + 5000)
    AddMessage("Where did you get all that oil?")

  elseif (str == "This is so ironic!") then
    SetPlayerResource(GetThisPlayer(), "iron",
      GetPlayerResource(GetThisPlayer(), "iron") + 5000)
    AddMessage("Sadistic, actually.")

  elseif (str == "Stonehenge") then
    SetPlayerResource(GetThisPlayer(), "stone",
      GetPlayerResource(GetThisPlayer(), "stone") + 5000)
    AddMessage("Duh.")

  elseif (str == "Batman") then
    AddMessage("Da da da da da da da da da da da da da da da da BATMAN!!")

  elseif (str == "Occupied") then
    AddMessage("Not enough food.")
    AddMessage("Last message repeated 14520 times.")
	
  elseif (str == "Powers") then
    AddMessage("I've got the power! Ye-he-he-heeyyaa!")

  elseif (str == "Joke1") then
    AddMessage("Where do bulls get their notes? - From the BULLetin board.")

  elseif (str == "Joke2") then
    AddMessage("What did three wise men say when they went into a cab? - Follow that star!")

  elseif (str == "Joke3") then
    AddMessage("Does your dog like children? - Yeah. But he likes more dog food.")

  elseif (str == "Joke4") then
    AddMessage("Why there is fat in the cow's milk? - So that the udder wouldn't squeak.")

  elseif (str == "Joke5") then
    AddMessage("You are married. - Yes I am. - And you are a father of two kids. - No, I'm the father of three kids. - That's what you think.")

  elseif (str == "Joke6") then
    AddMessage("Do you speak English? - Yes, a little. - How much? - 70 dollars.")

  elseif (str == "Joke7") then
    AddMessage("Have you ever told your own opinion to your wife? - Yes, wanna see the scars?")

  elseif (str == "Joke8") then
    AddMessage("Where do you know the world's dumbest hunter? - He tried to shoot in the air, but missed.")

  elseif (str == "Joke9") then
    AddMessage("What is that terrible noise in there? - Oh, Ernie is just talking to France in there... - Shouldn't he use the phone?")

  elseif (str == "Joke10") then
    AddMessage("What do you call a swedish guy with lots of laudaturs and badges? - A theif.")
	
  elseif (str == "Research, you fools!") then
    DefineAllow("upgrade-dwarves-level2",			"RAAAAAAAAAAAAAAA")
    DefineAllow("upgrade-dwarves-bowman",			"RAAAAAAAAAAAAAAA")
    DefineAllow("upgrade-dwarves-swordman",			"RAAAAAAAAAAAAAAA")
    DefineAllow("upgrade-dwarves-advanced-worker",		"RAAAAAAAAAAAAAAA")
    DefineAllow("upgrade-dwarves-agriculture",			"RAAAAAAAAAAAAAAA")
    DefineAllow("upgrade-dwarves-stone-working",		"RAAAAAAAAAAAAAAA")
    DefineAllow("upgrade-dwarves-ships",			"RAAAAAAAAAAAAAAA")
    AddMessage("We have done all of your researchs, my lord. At least, if you are player 0 (red)...")
  else
    return false
  end
  return true
end
