Вход Регистрация
Файл: ewar/class/deadly_fight.php
Строк: 654
<?php

    
class Deadly_Fight {
    
        private 
$uid;
        private 
$fight    = null;                                        #Kovos kėšas.
        
public    $uron    = 0;
        
        public function 
__construct($uid = null) {
        
            
$this -> uid = $uid;
        
        }
        
        public function 
updateResult($result) {
        
            
$this -> updateFight($this -> fight);
            
$this -> fight['result_data'] = $result;
            
            return 
$result;
        
        }
        
        private function 
cacheKey($type) {
        
            
$keys = array(
                
1 => 'deadly.fight',                                #Žaidėjo kėšas mirtiname susirėmime.
                
2 => 'deadly.fight.invite.from.player',                #Kvietimas į kovą nuo žaidėjo. 1 reikšmė.
                
3 => 'deadly.fight.invites.for.player',                #Visi kvietimai į kovą tam tikram žaidėjui.
                
4 => 'deadly.fight.info',                            #Žaidėjų informacija apie kovų skaičių ir pan.
                
5 => 'deadly.fight.log'                                #Mirtino susirėmimo paskutinių kovų informacija.
            
);
            
            return 
$keys[$type];
        
        }
        
        public function 
myCache() {
        
            
$CacheKey = $this -> cacheKey(4);
            
$Cache = readcache($CacheKey);
            
$insert = false;
            
            if (
$Cache === false) {
            
                
$Cache = array();
                
$insert = true;
            
            }
            
            if (!
array_key_exists($this -> uid, $Cache)) {
            
                
#Cache['user_id'] = array(likusių kovų skaičius):
                
$Cache[$this -> uid] = array(10);
                
$insert = true;
            
            }
            
            if (
$insert) {
            
                
writecache($CacheKey, $Cache);
            
            }
            
            return 
$Cache[$this -> uid];
        
        }
        
        public function 
updateFights($action = false) {
        
            
$CacheKey = $this -> cacheKey(4);
            
$Cache = readcache($CacheKey);
            
            if (
$action == 1) {
            
                
$Cache[$this -> uid][0] = $Cache[$this -> uid][0] == 10 ? 10 : $Cache[$this -> uid][0] + 1;
            
            }
            else if (
$action == 2) {
            
                
$Cache[$this -> uid][0] = $Cache[$this -> uid][0] - 1;
            
            }
            else
            {
            
                
$Cache[$this -> uid][0] = 10;
            
            }
            
            
writecache($CacheKey, $Cache);
        
        }
        
        public function 
inviteInFight($opponent_id, $gold, $silver) {
        
            
#$action:
            #1 - pakvietė žaidėją;
            #2 - atšaukė pakvietimą;
            #3 - neužtenka kvietimų.
            
            
$my_fights = $this -> myCache();
            
$myCacheKey = $this -> cacheKey(2).$this -> uid;
            
$opponentCacheKey = $this -> cacheKey(3).$opponent_id;
            
            
$myCache = readcache($myCacheKey);
            
$opponentCache = readcache($opponentCacheKey);
            
            if (
$myCache['opponent_id'] == $opponent_id) {
            
                if (
$myCache['gold'] > 0 or $myCache['silver'] > 0) {
                
                    
mysql_query("UPDATE `vartotojai` SET `g` = `g` + ".$myCache['gold'].", `s` = `s` + ".$myCache['silver']." WHERE `id` = '".($this -> uid)."'");
                
                }
                
                
$this -> updateFights(1);
                
                unset(
$myCache);
                unset(
$opponentCache[$this -> uid]);
                
                
$action = 2;
            
            }
            else
            {
            
                if (
is_array($myCache)) {
                
                    if (
$myCache['gold'] > 0 or $myCache['silver'] > 0) {
                    
                        
mysql_query("UPDATE `vartotojai` SET `g` = `g` + ".$myCache['gold'].", `s` = `s` + ".$myCache['silver']." WHERE `id` = '".($this -> uid)."'");
                    
                    }
                    
                    
$outsideOpponentCacheKey = $this -> cacheKey(3).$myCache['opponent_id'];
                    
$outsideOpponentCache = readcache($outsideOpponentCacheKey);
                    
                    unset(
$outsideOpponentCache[$this -> uid]);
                    unset(
$myCache);
                    
                    
writecache($outsideOpponentCacheKey, $outsideOpponentCache);
                
                }
                else
                {
                
                    if (
$my_fights[0] == false) {
                    
                        
$action = 3;
                    
                    }
                    else
                    {
                    
                        
$this -> updateFights(2);
                    
                    }
                
                }
                
                if (
$action != 3) {
                
                    if (
$gold or $silver) {
                    
                        
mysql_query("UPDATE `vartotojai` SET `g` = `g` - $gold, `s` = `s` - $silver WHERE `id` = '".($this -> uid)."'");
                    
                    }
                    
                    
$myCache = array('opponent_id' => $opponent_id, 'gold' => $gold, 'silver' => $silver);
                    
$opponentCache[$this -> uid] = array('gold' => $gold, 'silver' => $silver);
                    
                    
$action = 1;
                
                }
            
            }
            
            if (
$action != 3) {
            
                
writecache($myCacheKey, $myCache);
                
writecache($opponentCacheKey, $opponentCache);
            
            }
            
            return 
$action;
        
        }
        
        public function 
isInvited($opponent_id) {
        
            
$myCacheKey = $this -> cacheKey(2).$this -> uid;
            
$myCache = readcache($myCacheKey);
            
            if (
$myCache['opponent_id'] == $opponent_id) {
            
                return 
true;
            
            }
            else
            {
            
                return 
false;
            
            }
        
        }
        
        public function 
iHaveInvite() {
        
            
$myCacheKey = $this -> cacheKey(3).$this -> uid;
            
$myCache = readcache($myCacheKey);
            
            if(
$myCache) {
            
                foreach(
$myCache as $key => $value) {
                
                    
$invite = array('opponent_id' => $key, 'gold' => $value['gold'], 'silver' => $value['silver']);
                    
                    break;
                
                }
                
                return 
$invite;
            
            }
            else
            {
            
                return 
false;
            
            }
        
        }
        
        public function 
cancelInviteForMe($opponent_id, $back = false) {
        
            
$myCacheKey = $this -> cacheKey(3).$this -> uid;
            
$opponentCacheKey = $this -> cacheKey(2).$opponent_id;
            
            
$myCache = readcache($myCacheKey);
            
$opponentCache = readcache($opponentCacheKey);
            
            if (
$opponentCache['opponent_id'] == $this -> uid) {
            
                if ((
$opponentCache['gold'] > 0 or $opponentCache['silver'] > 0) && $back == true) {
                
                    
mysql_query("UPDATE `vartotojai` SET `g` = `g` + ".$opponentCache['gold'].", `s` = `s` + ".$opponentCache['silver']." WHERE `id` = '$opponent_id'");
                
                }
                
                unset(
$opponentCache);
                
                
writecache($opponentCacheKey, $opponentCache);
            
            }
            
            unset(
$myCache[$opponent_id]);
            
            
writecache($myCacheKey, $myCache);
        
        }
        
        public function 
initFight() {
        
            if (
is_null($this -> fight)) {
            
                
$cKey = $this -> cacheKey(1).$this -> uid;
                
$this -> fight = readcache($cKey);
                
                if (
$this -> fight === FALSE) {
                
                    
$this -> fight = null;
                
                }
            
            }
        
        }
        
        public function 
getFight() {
        
            if (
is_null($this -> fight)) {
            
                
$this -> initFight();
            
            }
            
            if (!
is_null($this -> fight)) {
            
                return 
$this -> fight;
            
            }
            
            return 
false;
        
        }
        
        public function 
updateFight($fight) {
        
            
$this -> fight = $fight;
            
            foreach (
$fight['users'] as $key => $value) {
            
                
$cKey = $this -> cacheKey(1).$key;
                
                
writecache($cKey, $fight);
            
            }
        
        }
        
        public function 
getUserParams($user_id) {
        
            return @
$this -> fight['users'][$user_id];
        
        }
        
        public function 
startFight($dm, $opponent, $prize) {
        
            
$mctime1 = explode(' ', microtime());
            
$mctime1[1] = $mctime1[1] - 5;
            
            
$this -> fight = array(
                
'type'        => 'fight',
                
'time'      => time() + 300,
                
'users'     => array(
                    
$dm['id']        => array(
                        
'battle_hp'             => $dm['vit'] * 2,
                        
'other_hp'             => $dm['vit'] * 2,
                        
'str'                 => $dm['str'],
                        
'def'                 => $dm['def'],
                        
'agi'                 => $dm['agi'],
                        
'name'                 => $dm['nick'],
                        
'statusas'             => $dm['statusas'],
                        
'akmuo_time'         => $dm['akmuo_time'],
                        
'zole_time'             => $dm['zole_time'],
                        
'microtime'             => ($mctime1[0].' '.$mctime1[1]),
                        
'uron'                 => false,
                        
'ability_1'          => $dm['ability_1'],
                        
'ability_2'          => $dm['ability_2'],
                        
'ability_3'          => $dm['ability_3'],
                        
'ability_4'          => $dm['ability_4'],
                        
'ability_5'          => $dm['ability_5'],
                        
'ability_1_quality' => $dm['ability_1_quality'],
                        
'ability_2_quality' => $dm['ability_2_quality'],
                        
'ability_3_quality' => $dm['ability_3_quality'],
                        
'ability_4_quality' => $dm['ability_4_quality'],
                        
'ability_5_quality' => $dm['ability_5_quality'],
                        
'skills'            => array(),
                        
'my_user_add_hp'    => 0,
                        
'opponent'            => $opponent['id'],
                        
'ip'                => $dm['ip']
                    ),
                    
$opponent['id']    => array(
                        
'battle_hp'             => $opponent['vit'] * 2,
                        
'other_hp'             => $opponent['vit'] * 2,
                        
'str'                 => $opponent['str'],
                        
'def'                 => $opponent['def'],
                        
'agi'                 => $opponent['agi'],
                        
'name'                 => $opponent['nick'],
                        
'statusas'             => $opponent['statusas'],
                        
'akmuo_time'         => $opponent['akmuo_time'],
                        
'zole_time'             => $opponent['zole_time'],
                        
'microtime'             => ($mctime1[0].' '.$mctime1[1]),
                        
'uron'                 => false,
                        
'ability_1'          => $opponent['ability_1'],
                        
'ability_2'          => $opponent['ability_2'],
                        
'ability_3'          => $opponent['ability_3'],
                        
'ability_4'          => $opponent['ability_4'],
                        
'ability_5'          => $opponent['ability_5'],
                        
'ability_1_quality' => $opponent['ability_1_quality'],
                        
'ability_2_quality' => $opponent['ability_2_quality'],
                        
'ability_3_quality' => $opponent['ability_3_quality'],
                        
'ability_4_quality' => $opponent['ability_4_quality'],
                        
'ability_5_quality' => $opponent['ability_5_quality'],
                        
'skills'            => array(),
                        
'my_user_add_hp'    => 0,
                        
'opponent'            => $dm['id'],
                        
'ip'                => $opponent['ip']
                    )
                ),
                
'winner_gold'     => $prize['gold'] * 2,
                
'winner_silver'     => $prize['silver'] * 2,
                
'journal'   => array()
            );
            
            
$this -> addJournal('<span class="lime">[kova_prasidejo*]</span>');
            
$this -> updateFight($this -> fight);
        
        }
        
        public function 
attack($dm) {
        
            
$final = false;
            
            
$myID = $dm['id'];
            
$opponentID = $this -> fight['users'][$myID]['opponent'];
            
            
$zenklas = @zenklas($this -> fight['users'][$myID]['statusas']);
            
$zenklas2 = @zenklas($this -> fight['users'][$opponentID]['statusas']);
            
            
$mSkills = skills($this -> fight['users'][$myID]['ability_1'], $this -> fight['users'][$myID]['ability_2'], $this -> fight['users'][$myID]['ability_3'], $this -> fight['users'][$myID]['ability_4'], $this -> fight['users'][$myID]['ability_5']);
            
$oSkills = skills($this -> fight['users'][$opponentID]['ability_1'], $this -> fight['users'][$opponentID]['ability_2'], $this -> fight['users'][$opponentID]['ability_3'], $this -> fight['users'][$opponentID]['ability_4'], $this -> fight['users'][$opponentID]['ability_5']);
            
            
$this -> fight['users'][$myID]['my_user_add_hp'] = 0;
            
$usr_params = array('str' => $this -> fight['users'][$myID]['str'], 'agi' => $this -> fight['users'][$myID]['agi'], 'def' => $this -> fight['users'][$myID]['def'], 'akmuo_time' => @$this -> fight['users'][$myID]['akmuo_time']);
            
$opponent_params = array('def' => $this -> fight['users'][$opponentID]['def'], 'zole_time' => @$this -> fight['users'][$opponentID]['zole_time'], 'skills' => array(2 => @$oSkills[2], 4 => @$oSkills[4]));
            
$myInfo = genUron(2, $this -> fight['users'][$myID]['microtime'], $usr_params, $opponent_params, $mSkills);
            
$log_crit = $myInfo[1];
            
            if (
count($mSkills) > 0) {
            
                
$this -> fight['users'][$myID]['skills'] = array();
                
                if (
$mSkills[1]['active'] == true) {
                
                    
$this -> addJournal('<span class="small yellow"><span class="lime"><img src="img/icons/player.png" alt="*"/> '.$zenklas.''.$this -> fight['users'][$myID]['name'].'</span> [panaudojo*] <img src='img/items/quality/'.$this -> fight['users'][$myID]['ability_1_quality'].'.png'> <span class='quality-'.$this -> fight['users'][$myID]['ability_1_quality'].''>[titano_ituzis*]</span>.</span>');
                    
$this -> fight['users'][$myID]['skills'][1] = $this -> fight['users'][$myID]['ability_1_quality'];
                
                }
                
                if (
$mSkills[3]['active'] == true && $log_crit == true) {
                
                    
$this -> addJournal('<span class="small yellow"><span class="lime"><img src="img/icons/player.png" alt="*"/> '.$zenklas.''.$this -> fight['users'][$myID]['name'].'</span> [panaudojo*] <img src='img/items/quality/'.$this -> fight['users'][$myID]['ability_3_quality'].'.png'> <span class='quality-'.$this -> fight['users'][$myID]['ability_3_quality'].''>[kritu_viesulas*]</span>.</span>');
                    
$this -> fight['users'][$myID]['skills'][3] = $this -> fight['users'][$myID]['ability_3_quality'];
                
                }
                
                if (
$mSkills[5]['active'] == true && $myInfo[1] > 0) {
                
                    
$kiek = round(($this -> fight['users'][$opponentID]['battle_hp'] / 100) * $mSkills[5]['bonus']);
                    
$this -> fight['users'][$myID]['battle_hp'] += $kiek;
                    
                    if (
$this -> fight['users'][$myID]['battle_hp'] > $this -> fight['users'][$myID]['other_hp']) {
                    
                        
$this -> fight['users'][$myID]['battle_hp'] = $this -> fight['users'][$myID]['other_hp'];
                        
$kiek = $this -> fight['users'][$myID]['other_hp'] - $this -> fight['users'][$myID]['battle_hp'];
                    
                    }
                    
                    
$this -> fight['users'][$opponentID]['battle_hp'] -= $kiek;
                    
$this -> fight['users'][$myID]['my_user_add_hp'] = $kiek;
                    
                    
$this -> addJournal('<span class="small yellow"><span class="lime"><img src="img/icons/player.png" alt="*"/> '.$zenklas.''.$this -> fight['users'][$myID]['name'].'</span> [panaudojo*] <img src='img/items/quality/'.$this -> fight['users'][$myID]['ability_5_quality'].'.png'> <span class='quality-'.$this -> fight['users'][$myID]['ability_5_quality'].''>[vampyrizmas*]</span>.</span>');
                    
$this -> fight['users'][$myID]['skills'][5] = $this -> fight['users'][$myID]['ability_5_quality'];
                
                }
            
            }
            
            if (
count($oSkills) > 0) {
            
                if (
$oSkills[2]['active'] == true) {
                
                    
$this -> addJournal('<span class="small yellow"><span class="red"><img src="img/icons/player.png" alt="*"/> '.$zenklas2.''.$this -> fight['users'][$opponentID]['name'].'</span> [panaudojo*] <img src='img/items/quality/'.$this -> fight['users'][$opponentID]['ability_2_quality'].'.png'> <span class='quality-'.$this -> fight['users'][$opponentID]['ability_2_quality'].''>[galinga_gynyba*]</span>.</span>');
                
                }
                
                if (
$oSkills[4]['active'] == true && $log_crit == true) {
                
                    
$this -> addJournal('<span class="small yellow"><span class="red"><img src="img/icons/player.png" alt="*"/> '.$zenklas2.''.$this -> fight['users'][$opponentID]['name'].'</span> [panaudojo*] <img src='img/items/quality/'.$this -> fight['users'][$opponentID]['ability_4_quality'].'.png'> <span class='quality-'.$this -> fight['users'][$opponentID]['ability_4_quality'].''>[apsaugine_stovesena*]</span>.</span>');
                
                }
            
            }
            
            if (
$myInfo[0] > $this -> fight['users'][$opponentID]['battle_hp']) {
            
                
$myInfo[0] = $this -> fight['users'][$opponentID]['battle_hp'];
            
            }
            
            
$this -> addJournal('<span class="small yellow"><span class="lime"><img src="img/icons/player.png" alt="*"/> '.$zenklas.''.$this -> fight['users'][$myID]['name'].'</span> [smoge*] <span class="red"><img src="img/icons/player.png" alt="*"/> '.$zenklas2.''.$this -> fight['users'][$opponentID]['name'].'</span> [su*] <span class="bold">'.$myInfo[0].'</span> [zala*]'.(($myInfo[1]) ? ' [krit*].' : '.').'</span>');
            
            
$this -> fight['users'][$opponentID]['battle_hp'] -= $myInfo[0];
            
$this -> fight['users'][$opponentID]['uron'] = $myInfo[0];
            
$this -> fight['users'][$myID]['microtime'] = microtime();
            
            
#Priešininko nužudymas:
            
if ($this -> fight['users'][$opponentID]['battle_hp'] <= 0) {
            
                
$this -> addJournal('<span class="small yellow"><span class="lime"><img src="img/icons/player.png" alt="*"/> '.$zenklas.''.$this -> fight['users'][$myID]['name'].'</span> [nuzude*] <span class="red"><img src="img/icons/player.png" alt="*"/> '.$zenklas2.''.$this -> fight['users'][$opponentID]['name'].'</span>.</span>');
                
                
$final = $this -> finalFight($dm, $myID);
            
            }
            
            
$this -> updateFight($this -> fight);
            
            return 
$final;
        
        }
        
        public function 
getResult() {
        
            return @
$this -> fight['result_data'];
        
        }
        
        public function 
finalFight($dm, $winner, $endtime = false) {
        
            
$this -> fight['type'] = 'result';
            
$lost = $this -> fight['users'][$winner]['opponent'];
            
$zenklas = @zenklas($this -> fight['users'][$winner]['statusas']);
            
$zenklas2 = @zenklas($this -> fight['users'][$lost]['statusas']);
            
            if (
$endtime == true) {
            
                
$this -> fight['result_data'] = array(
                    
'winner'     => $winner,
                    
'exp_win'    => 20,
                    
'exp_lost'    => 20,
                    
'gold'        => 0,
                    
'silver'    => 0,
                    
'endtime'    => true
                
);
                
                
$text = '<span class="small yellow"><img src="img/icons/player.png" alt="*"/> <a href="index.php?id=info&amp;k='.$winner.'"><span class="lime">'.$zenklas.''.$this -> fight['users'][$winner]['name'].'</span></a> [kovojo_pries*] <img src="img/icons/player.png" alt="*"/> <a href="index.php?id=info&amp;k='.$lost.'"><span class="red">'.$zenklas2.''.$this -> fight['users'][$lost]['name'].'</span></a>.<br/><span class="small2">[pasibaige_kovos_laikas*] <img src="img/icons/clock.png" alt="*"/>.<br/>'.date("Y-m-d H:i:s").'</span></span>';
            
            }
            else if(
$this -> fight['users'][$winner]['ip'] == $this -> fight['users'][$lost]['ip']) {
            
                
$this -> fight['result_data'] = array(
                    
'winner'     => $winner,
                    
'exp_win'    => 20,
                    
'exp_lost'    => 20,
                    
'gold'        => 0,
                    
'silver'    => 0,
                    
'endtime'    => false
                
);
                
                
$text = '<span class="small yellow"><img src="img/icons/player.png" alt="*"/> <a href="index.php?id=info&amp;k='.$winner.'"><span class="lime">'.$zenklas.''.$this -> fight['users'][$winner]['name'].'</span></a> [nugalejo*] <img src="img/icons/player.png" alt="*"/> <a href="index.php?id=info&amp;k='.$lost.'"><span class="red">'.$zenklas2.''.$this -> fight['users'][$lost]['name'].'</span></a>.<br/><span class="small2">'.date("Y-m-d H:i:s").'</span></span>';
            
            }
            else
            {
            
                
$this -> fight['result_data'] = array(
                    
'winner'     => $winner,
                    
'exp_win'    => (rand(6,8) + $this -> fight['users'][$lost]['level']) * 3,
                    
'exp_lost'    => 20,
                    
'gold'        => $this -> fight['winner_gold'],
                    
'silver'    => $this -> fight['winner_silver'],
                    
'endtime'    => false
                
);
                
                
$text = '<span class="small yellow"><img src="img/icons/player.png" alt="*"/> <a href="index.php?id=info&amp;k='.$winner.'"><span class="lime">'.$zenklas.''.$this -> fight['users'][$winner]['name'].'</span></a> [nugalejo*] <img src="img/icons/player.png" alt="*"/> <a href="index.php?id=info&amp;k='.$lost.'"><span class="red">'.$zenklas2.''.$this -> fight['users'][$lost]['name'].'</span></a>.'.(($this -> fight['result_data']['gold'] > 0 or $this -> fight['result_data']['silver'] > 0) ? '<br/><span class="small2">[nugaletojo_prizas*]: '.(($this -> fight['result_data']['gold'] > 0) ? '<img src="img/icons/gold.png" alt="*"/> '.n_f($this -> fight['result_data']['gold']).'' : '').''.(($this -> fight['result_data']['silver'] > 0) ? ' <img src="img/icons/silver.png" alt="*"/> '.n_f($this -> fight['result_data']['silver']).'' : '').'.' : '').'<br/>'.date("Y-m-d H:i:s").'</span></span>';
            
            }
            
            
$CacheKey = $this -> cacheKey(5);
            
$Cache = readcache($CacheKey);
            
            if (
$Cache === false) {
            
                
$Cache = array();
            
            }
            
            
array_unshift($Cache, $text);
            
            
$count = count($Cache);
            
            if (
$count > 200) {
            
                for(
$i = 201; $i < $count; $i ++) {
                
                    unset(
$Cache[$i]);
                
                }
            
            }
            
            
writecache($CacheKey, $Cache);
            
            
mysql_query("UPDATE `vartotojai` SET `g` = `g` + ".$this -> fight['result_data']['gold'].", `s` = `s` + ".$this -> fight['result_data']['silver'].", `exp` = `exp` + ".$this -> fight['result_data']['exp_win']." WHERE `id` = '$winner' LIMIT 1");
            
mysql_query("UPDATE `vartotojai` SET `exp` = `exp` + ".$this -> fight['result_data']['exp_lost']." WHERE `id` = '$lost' LIMIT 1");
            
            
$this -> updateFight($this -> fight);
            
            return 
$this -> fight['result_data'];
        
        }
        
        public function 
activeAkmuo($dm) {
        
            
$zenklas = @zenklas($this -> fight['users'][$dm['id']]['statusas']);
            
$this -> fight['users'][$dm['id']]['akmuo_time'] = time() + 60;
            
$this -> addJournal('<span class="small yellow"><span class="lime"><img src="img/icons/player.png" alt="*"/> '.$zenklas.''.$this -> fight['users'][$dm['id']]['name'].'</span> [panaudojo*] <img src="img/icons/stone_min.png" alt="*"/> [akmeni_ka*].</span>');
            
$this -> updateFight($this -> fight);
            
            
mysql_query("UPDATE `vartotojai` SET `akmuo` = `akmuo` - 1 WHERE `id` = '".$dm['id']."' LIMIT 1");
        
        }
        
        public function 
activeZole($dm) {
        
            
$zenklas = @zenklas($this -> fight['users'][$dm['id']]['statusas']);
            
$this -> fight['users'][$dm['id']]['zole_time'] = time() + 60;
            
$this -> addJournal('<span class="small yellow"><span class="lime"><img src="img/icons/player.png" alt="*"/> '.$zenklas.''.$this -> fight['users'][$dm['id']]['name'].'</span> [panaudojo*] <img src="img/icons/grass_min.png" alt="*"/> [zole_ka*].</span>');
            
$this -> updateFight($this -> fight);
            
            
mysql_query("UPDATE `vartotojai` SET `zole` = `zole` - 1 WHERE `id` = '".$dm['id']."' LIMIT 1");
        
        }
        
        public function 
getJournal() {
        
            return 
$this -> fight['journal'];
        
        }
        
        private function 
addJournal($text) {
        
            
array_unshift($this -> fight['journal'], $text);
            
            
$count = count($this -> fight['journal']);
            
            if (
$count > 15) {
            
                for(
$i = 16; $i < $count; $i ++) {
                
                    unset(
$this -> fight['journal'][$i]);
                
                }
            
            }
        
        }
        
        public function 
d_journal(array $journal) {
        
            global 
$language;
            
            foreach(
$journal as $value) {
            
                
$value = str_replace('[kova_prasidejo*]', $language['kova_prasidejo'], $value);
                
$value = str_replace('[akmeni_ka*]', $language['akmeni_ka'], $value);
                
$value = str_replace('[zole_ka*]', $language['zole_ka'], $value);
                
$value = str_replace('[panaudojo*]', $language['panaudojo'], $value);
                
$value = str_replace('[titano_ituzis*]', $language['titano_ituzis'], $value);
                
$value = str_replace('[galinga_gynyba*]', $language['galinga_gynyba'], $value);
                
$value = str_replace('[kritu_viesulas*]', $language['kritu_viesulas'], $value);
                
$value = str_replace('[apsaugine_stovesena*]', $language['apsaugine_stovesena'], $value);
                
$value = str_replace('[vampyrizmas*]',$language['vampyrizmas'],$value);
                
$value = str_replace('[smoge*]', $language['smoge'], $value);
                
$value = str_replace('[su*]', $language['su'], $value);
                
$value = str_replace('[zala*]', $language['zala'], $value);
                
$value = str_replace('[krit*]', $language['krit'], $value);
                
$value = str_replace('[nuzude*]', $language['nuzude'], $value);
                
                echo 
$value."<br/>";
            
            }
        
        }
        
        public function 
getLog() {
        
            
$CacheKey = $this -> cacheKey(5);
            
$Log = readcache($CacheKey);
            
            if (
$Log === false) {
            
                
$Log = array();
            
            }
            
            return 
$Log;
        
        }

        public function 
updateLog($key) {
        
            
$CacheKey = $this -> cacheKey(5);
            
$Log = readcache($CacheKey);
            
            if (
$Log === false) {
            
                
$Log = array();
            
            }
            else
            {

                unset(
$Log[$key]);

            }
            
            
writecache($CacheKey, $Log);
        
        }
    
    }

?>
Онлайн: 1
Реклама