PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Hossam Suliman  >  Simple PHP Combat System  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example of class usage.
Class: Simple PHP Combat System
Simulate a combat with attacker and defender army
Author: By
Last change:
Date: 1 year ago
Size: 768 bytes
 

Contents

Class file image Download
<?php

/**
 * Example of SimpleCombat class usage.
 *
 * @version: 1.0
 * @author: HossamZee.
 * @date: 8 May 2013.
 */

require_once("./SimpleCombat.class.php");


/* Define a new SimpleCombat class. */
$simpleCombat = new SimpleCombat();

/* Set the attacker troops. */
$simpleCombat->setAttackerTroops(
    array(
       
SimpleCombat::UNIT_MAN_WITH_HAND => 27,
       
SimpleCombat::UNIT_MAN_WITH_SWITCHBLADE => 13,
       
SimpleCombat::UNIT_MAN_WITH_GUN => 2,
    )
);

/* Set the defender troops. */
$simpleCombat->setDefenderTroops(
    array(
       
SimpleCombat::UNIT_MAN_WITH_HAND => 4,
       
SimpleCombat::UNIT_MAN_WITH_SWITCHBLADE => 10,
       
SimpleCombat::UNIT_MAN_WITH_GUN => 1,
    )
);

/* Go battle. */
$simpleCombat->battle();

/* Represent the battle. */
$simpleCombat->representBattle();