Code Search for Developers
 
 
  

State.php from Astrum Futura at Krugle


Show State.php syntax highlighted

<?php
/**
 * @internal
 * Quantum Game Library
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the text file LICENSE located in the root
 * directory of this library.
 * It is also available through the internet at this URL:
 * http://doc.astrumfutura.com/license.html
 *
 * If you did not receive a copy of the license and are unable to
 * obtain it through the internet, please send an email
 * to license@astrumfutura.com so we can send you a copy.
 *
 * @package    State
 * @category   AI
 * @copyright  Copyright (c) 2007 The QGL Group (refer to COPYRIGHT file)
 * @version    $Id: State.php 210 2007-02-03 02:55:49Z santosj $
 * @license    http://doc.astrumfutura.com/license.html     New BSD License
 */

/** Quantum_State_Abstract */
require_once 'Quantum/State/Abstract.php';

/**
 * The cutesy way of managing States, for a more sane method, use the 
 * Quantum_State_Abstract and extend it for your finite states.
 * 
 * @package    State
 * @category   AI
 * @author     Jacob Santos (http://www.santosj.name)
 */
class Quantum_State
    extends Quantum_State_Abstract
{
    private $states = array();
    
    private function __clone()
    {
        // Forbid cloning
    }
    
    public function append(Quantum_State_Transition $transition)
    {
        $name = $transition->getState();
        $this->states[$name] = $transition;
    }
    
    /**
     * process() - Processing will stop at the first completed action.
     * 
     * If you need to handle more than one condition, then you'll need to be
     * more specific in what classes you use.
     *
     */
    public function process()
    {
        foreach($this->states as $transition)
        {
            if($transition->execute($this->value) === true)
            {
                break;
            }
        }
    }
    
}



See more files for this project here

Astrum Futura

Multiplayer space strategy game written in PHP5 with the Zend Framework. User interface uses Javascript/AJAX for dynamic interaction. Players compete across a hexagonal map of 10,000 sectors, planets, stars and other locations through trade and combat.

Project homepage: http://sourceforge.net/projects/astrumfutura
Programming language(s): PHP,XML
License: other

  Coordinate/
    Array/
      Interface.php
    Boundary/
      Abstract.php
      Auto.php
      Exception.php
      Manual.php
    Exception/
      InvalidArray.php
      InvalidIndex.php
      InvalidX.php
      InvalidY.php
      InvalidZ.php
      RemovalFailure.php
    Node/
      Blocked.php
      End.php
      Impassable.php
      Interface.php
      Open.php
      Passable.php
      Planet.php
      Star.php
      Start.php
    Array.php
    Boundary.php
    Exception.php
    Index.php
    Interface.php
  Db/
    Access/
      Exception.php
      Interface.php
    Driver/
      Pdo/
        Abstract.php
        Mysql.php
      Exception.php
      Interface.php
    Schema/
      Exception.php
      Xml.php
    Access.php
    Db.php
    Exception.php
    NamedQueries.php
    NamedQueries.xml
    Row.php
  Map/
    Grid/
      Abstract.php
      Exception.php
      Hex.php
      Square.php
    Measure/
      Abstract.php
      Exception.php
      Hex.php
      Square.php
    Placement/
      Interface.php
    Star/
      Generate/
        Interface.php
        Simple.php
      Position/
        Interface.php
        Random.php
    Exception.php
  State/
    Action/
      Function.php
      Interface.php
      Method.php
    Condition/
      Boolean.php
      Contains.php
      Equality.php
      Greater.php
      Interface.php
      Less.php
      Range.php
    Abstract.php
    Condition.php
    Exception.php
    Transition.php
  Turing/
    Exception.php
    Interface.php
    Math.php
  Coordinate.php
  Db.php
  Exception.php
  Map.php
  State.php