rerollpermanencedie.php

<? include 'xmlheader.php'?>
<?
echo "<?xml version=\"1.0\" ?>";?>
<root>
<?php
    
include 'include.php';

    
openDatabase();

    
$gameid getGameId();

    
//This file rerolls a single permanence die

     
$sGetDiceQuery "SELECT permanencedice, permanentattraction, temporaryattraction, permanencererolls, permanencefailures, permanencesuccesses FROM game WHERE `gameid` = ".$gameid;

     
$rowReturn queryDatabaseForSingleRow($sGetDiceQuery);

     
$permanencedice $rowReturn["permanencedice"];
     
$permanentattraction $rowReturn["permanentattraction"];
     
$temporaryattraction $rowReturn["temporaryattraction"];
     
$permanencererolls $rowReturn["permanencererolls"];
     
$permanencesuccesses $rowReturn["permanencesuccesses"];
     
$permanencefailures $rowReturn["permanencefailures"];

     if (
$permanencererolls)
     {
     if (
$temporaryattraction 0)
     {
            if (
rand(16) > 4)
         {
             
$permanentattraction ++;
             
$temporaryattraction --;
             
$permanencesuccesses ++;
         }
         else
         {
             
$permanencefailures ++;
         }

         
$permanencererolls--;
     }
     }

    if (
$temporaryattraction $permanencedice $permanencererolls)
    {
        
$temporaryattraction $permanencedice $permanencererolls;
    }

    
$sUpdateQuery "UPDATE game SET permanentattraction = ".$permanentattraction.", temporaryattraction = ".$temporaryattraction.", permanencererolls= ".$permanencererolls.", permanencefailures = ".$permanencefailures.", permanencesuccesses = ".$permanencesuccesses." WHERE gameid = ".$gameid;
 
    echo 
$sUpdateQuery;

    
updateDatabase($sUpdateQuery);

    
outputXmlTag("permanentattraction"$permanentattraction);
    
outputXmlTag("temporaryattraction"$temporaryattraction);
    
outputXmlTag("permanencererolls"$permanencererolls);
    
outputXmlTag("permanencefailures"$permanencefailures);
    
outputXmlTag("permanencesuccesses"$permanencesuccesses);
   
    
closeDatabase();
?>
</root>