function run(&$xml_reponse, $p)
 {
     $clientid = $p["clientid"];
     $param = $p["param"];
     $sender = $p["sender"];
     $recipient = $p["recipient"];
     $recipientid = $p["recipientid"];
     $u =& pfcUserConfig::Instance();
     $nick = $u->nick;
     $ct =& pfcContainer::Instance();
     $text = trim($param);
     // Call parse roll
     require_once dirname(__FILE__) . '/demo27_dice.class.php';
     $dice = new Dice();
     if (!$dice->check($text)) {
         $result = $dice->error_get();
         $cmdp = $p;
         $cmdp["param"] = "Cmd_roll failed: " . $result;
         $cmd =& pfcCommand::Factory("error");
         $cmd->run($xml_reponse, $cmdp);
     } else {
         $result = $dice->roll();
         $ct->write($recipient, $nick, "send", $result);
     }
 }
예제 #2
0
 public static function checkforbunkdice()
 {
     self::$bunk = true;
     for ($x = 0; $x < count(self::$ActiveDiceList); $x++) {
         if (in_array(self::$ActiveDiceList[$x], self::$FrozenDiceList) == false) {
             self::$bunk = false;
         }
     }
 }
예제 #3
0
#!/usr/bin/php

<?php 
require 'Dice.php';
if ($argc != 2 || in_array($argv[1], array('--help', '-help', '-h', '-?'))) {
    print "Usage: {$argv['0']} <roll code>\n";
    print "\n";
    print "Where <roll code> is the die roll code grammar to test\n";
    print "\n";
    exit;
} else {
    $roll = $argv[1];
}
$parser = new Dice($roll);
$res = $parser->match_roll();
if ($res === FALSE) {
    print "No Match\n";
} else {
    print_r($res);
}
예제 #4
0
        //        print($this->diceName);
        //        print("<br>");
        print $this->diceNumber;
    }
}
echo "Dice 1:<br>";
$dice1 = new Dice();
$dice1->setSides(4);
$dice1->roll();
print $dice1->result();
//echo $dice1->roll();
//$dice2 = new Dice();
//echo $dice2->roll();
echo "<br>";
echo "Dice 2:<br>";
$dice2 = new Dice();
$dice2->setSides(300);
$dice2->roll();
print $dice2->result();
var_dump($dice1);
var_dump($dice2);
class Person
{
    //public
    //kan nås av alla alltid - allt möjligt
    //
    //protected
    //kan nås/ändras av saker inuti klassen enbart och dess barn
    //
    //private
    //kan nås enbart denna klass, ej barn
예제 #5
0
<?php

class Dice
{
    public $faces = 6;
    public function roll()
    {
        return rand(1, $this->faces);
    }
}
$dice = new Dice();
echo $dice->roll() . "\n";
$dice->faces = 32;
echo $dice->roll() . "\n";
class DiceAlphabetic
{
    public $faces = 6;
    public static $images = ["A", "B", "C", "D", "E", "F"];
    public function roll()
    {
        return self::$images[rand(0, $this->faces - 1)];
    }
}
$dice = new DiceAlphabetic();
echo "\n";
echo $dice->roll() . "\n";
echo $dice->roll() . "\n";
echo print_r(DiceAlphabetic::$images, 1) . "\n";
예제 #6
0
 public function repair(Dice $dice)
 {
     if ($_pp <= 0) {
         return FALSE;
     }
     $ret = $dice->throw();
     if ($ret == 6) {
         $this->_life += 1;
         if ($this->_life > $this->_maxlife) {
             $this->_life = $this->_maxlife;
         }
     }
 }
예제 #7
0
/**
 * Author: Rene Kremer
 * Date: 20.08.15
 * Time: 13:27
 * Version 1.0
 *
 * Description: Main App to roll the dices
 */
include 'templates/template.class.php';
include "dice.class.php";
$template = new Template("templates", "img");
$template->header();
$template->head();
// check if first time or reroll
if (isset($_GET["dice"]) || isset($_GET["numberOfDices"])) {
    $dice = new Dice($_GET["dice"], $_GET["numberOfDices"]);
    $value = $_GET["dice"];
} else {
    if (isset($_POST["dice"]) && isset($_POST["dice"])) {
        $dice = new Dice($_POST["dice"], $_POST["numberOfDices"]);
        $value = $_POST["dice"];
    } else {
        //echo file_get_contents("templates/errorWrongDice.tpl");
        return false;
    }
}
if (!$dice->wrongDice && $template->showDice($value)) {
    $dice->roll();
}
$template->follow();
$template->footer();
 public function makeDamage(Weapon $weapon)
 {
     $damage = Dice::nextStatic($weapon->getDamageRange()) + $weapon->getStrikeForce();
     $health = $this->getHealth() - $damage;
     $this->setHealth($health);
     return ['damage' => $damage, 'remaining_health' => $health];
 }
예제 #9
0
 public function testValuesFace()
 {
     $dice = new Dice();
     // Asserts
     $this->assertContains($dice->value(), array(1, 2, 3, 4, 5, 6));
 }
예제 #10
0
파일: Bid.php 프로젝트: eltonmoura/dadinho
 public function isValid()
 {
     return is_int($this->quantity) && $this->quantity >= 0 && Dice::validFace($this->value);
 }