Source

Selador / php / event.php

Full commit
<?php

/* event.php - Back-end code for dealing with events
 *
 * Copyright (C) 2006, 2007, 2008 Kevin Read, Simone Schaefer
 *
 * This file is part of Selador, a browser-based fantasy strategy game
 *
 * This program is distributed under the terms of the GNU Affero General Public License.
 *
 *
 *   Selador is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Affero General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   any later version.
 *
 *   Selador 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 Affero General Public License for more details.
 *
 *   You should have received a copy of the GNU Affero General Public License
 *   along with Selador.  If not, see <http://www.gnu.org/licenses/>.
 **/

$eventmap = array (1000 => "Enklave", 1001 => "Farmland", 1002 => "Holzf&auml;ller", 1003 => "Steinbruch", 1004 => "Eisenmine");

$coinmap = array (1=>"Holz", 2=>"Stein", 3=>"Eisen", 4=>"Nahrung", 5=>"Gold");
$coinpicmap = array (1=>"gfx/holz.gif", 2=>"gfx/lehm.gif", 3=>"gfx/iron.gif", 4=>"gfx/food.gif", 5=>"gfx/mana.gif");

/* Define all used event types, so the code is nicer. If you add new events,
 * add them here. */

define ("BUILDING", 1);
define ("RESEARCH", 2);
define ("RECRUITING", 3);
define ("ATTACK", 4);
define ("SPY", 5);
define ("SUPPORT", 6);
define ("RAID", 7);
define ("RETURNING", 10);
define ("TRANSPORT", 11);
define ("MOVE", 12);
define ("SIEGE", 13);
define ("SIEGE_END", 14);
define ("GROUPATTACK", 18);
define ("GROUPATTACK_PART", 19);
define ("GROUPATTACK_INV", 20);
define ("RL_ALLY_DIPL", 50);
define ("HERO_RETURNS", 51);
define ("BUILDING_DELEGATE", 70);
define ("RESEARCH_DELEGATE", 71);
define ("RESSOURCE_DELEGATE", 72);
define ("SIEGE_END_DELEGATE", 73);


// Check to see if this event is already in the build queue
function check_event_village2 ($uid, $villageid, $type, $param, $village2)
{
  $query = "select eid from event where uid1=".$uid." and village1=".$villageid." and type=".$type." and param=".$param." and village2=".$village2;

  $res = mysql_query ($query);

  if (mysql_num_rows ($res) > 0)
  {
    log_debug ("Check_event_village2: Query: ".$query." is true");
    return true;
  }
  else
  {
    log_debug ("Check_event_village2: Query: ".$query." is false");
    return false;
  }
}

// Check to see if this event is already in the build queue
function check_event_param2 ($uid, $villageid, $type, $param, $param2)
{
  $query = "select eid from event where uid1=".$uid." and type=".$type." and param=".$param." and param2=".$param2;

  $res = mysql_query ($query);

  if (mysql_num_rows ($res) > 0)
  {
    log_debug ("Check_event_param2: Query: ".$query." is true");
    return true;
  }
  else
  {
    log_debug ("Check_event_param2: Query: ".$query." is false");
    return false;
  }
}

?>