Skip to content

Commit

Permalink
Залил файлы.
Browse files Browse the repository at this point in the history
  • Loading branch information
devapromix committed Sep 9, 2021
1 parent a3a1697 commit 2955413
Show file tree
Hide file tree
Showing 18 changed files with 1,978 additions and 0 deletions.
66 changes: 66 additions & 0 deletions server/lizardry/common/common.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
$username = $_GET['username'];
$userpass = $_GET['userpass'];

if ($username == '') die('21');
if ($userpass == '') die('22');

if (strlen($username) < 4) die('31');
if (strlen($userpass) < 4) die('32');

if (strlen($username) > 24) die('41');
if (strlen($userpass) > 24) die('42');

function save_character() {
global $user_name, $user_pass, $char_name, $char_level, $char_exp, $char_food, $char_gold, $char_bank,
$char_equip_weapon, $char_equip_armor, $char_damage_min, $char_damage_max, $char_armor,
$char_str, $char_dex, $char_int, $char_per, $char_life_cur, $char_life_max, $char_mana_cur, $char_mana_max,
$char_inv_hppotion,
$char_x, $char_y, $char_stat_kills, $char_stat_deads, $char_monster;

$file .= "<?php\n\n";

$file .= '$user_name = "'.$user_name.'";'."\n";
$file .= '$user_pass = "'.$user_pass.'";'."\n";
$file .= '$char_name = "'.$char_name.'";'."\n";
$file .= '$char_level = '.$char_level.';'."\n";
$file .= '$char_exp = '.$char_exp.';'."\n";
$file .= '$char_food = '.$char_food.';'."\n";
$file .= '$char_gold = '.$char_gold.';'."\n";
$file .= '$char_bank = '.$char_bank.';'."\n";
$file .= '$char_equip_weapon = '.$char_equip_weapon.';'."\n";
$file .= '$char_equip_armor = '.$char_equip_armor.';'."\n";
$file .= '$char_damage_min = '.$char_damage_min.';'."\n";
$file .= '$char_damage_max = '.$char_damage_max.';'."\n";
$file .= '$char_armor = '.$char_armor.';'."\n";
$file .= '$char_str = '.$char_str.';'."\n";
$file .= '$char_dex = '.$char_dex.';'."\n";
$file .= '$char_int = '.$char_int.';'."\n";
$file .= '$char_per = '.$char_per.';'."\n";
$file .= '$char_life_cur = '.$char_life_cur.';'."\n";
$file .= '$char_life_max = '.$char_life_max.';'."\n";
$file .= '$char_mana_cur = '.$char_mana_cur.';'."\n";
$file .= '$char_mana_max = '.$char_mana_max.';'."\n";
$file .= '$char_inv_hppotion = '.$char_inv_hppotion.';'."\n";
$file .= '$char_x = '.$char_x.';'."\n";
$file .= '$char_y = '.$char_y.';'."\n";
$file .= '$char_stat_kills = '.$char_stat_kills.';'."\n";
$file .= '$char_stat_deads = '.$char_stat_deads.';'."\n";
$file .= '$char_monster = '.$char_monster.';'."\n";

$file .= "\n?>";

file_put_contents('../characters/character.'.$user_name.'.php', $file);
}

function all_response() {
global $char_name, $char_level, $char_exp, $char_food, $char_gold, $char_life_cur, $char_life_max;
return "|all:".$char_name.":".$char_level.":".$char_exp.":".$char_food.":".$char_gold.":".$char_life_cur.":".$char_life_max;
}

function rest_response() {
global $char_gold, $char_food, $char_life_cur, $char_life_max;
return "|rest:".$char_gold.":".$char_food.":".$char_life_cur.":".$char_life_max;
}

?>
254 changes: 254 additions & 0 deletions server/lizardry/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
<?php
$res = '0';

include 'common/common.php';

$action = $_GET['action'];
$amount = $_GET['amount'];

if (file_exists('characters/character.'.$username.'.php')) {
require_once 'characters/character.'.$username.'.php';
if (($userpass != '')&&($userpass == $user_pass)) {
if ($action == 'login') {
$res = '1';
}
if ($action == 'get_character_info') {
$res =
$char_name."\n".
$char_level."\n".
$char_exp."\n".
$char_food."\n".
$char_gold."\n".
$char_bank."\n".
$char_equip_weapon."\n".
$char_equip_armor."\n".
$char_damage_min."\n".
$char_damage_max."\n".
$char_armor."\n".

$char_str."\n".
$char_dex."\n".
$char_int."\n".
$char_per."\n".
$char_life_cur."\n".
$char_life_max."\n".
$char_mana_cur."\n".
$char_mana_max."\n".

$char_inv_hppotion."\n".

$char_x."\n".
$char_y."\n".

$char_stat_kills."\n".
$char_stat_deads."\n";

$char_monster."\n";
}
if ($action == 'get_gold_info') {
$res = $char_gold."\n".
$char_bank."\n";
}
if ($action == 'deposit') {
if ($amount <= 0)
$res = die('e1');
if ($amount > $char_gold)
$res = die('e2');
$char_gold = $char_gold - $amount;
$char_bank = $char_bank + $amount;
save_character();
$res = $char_gold."\n".
$char_bank."\n";
}
if ($action == 'withdraw') {
if ($amount <= 0)
$res = die('e1');
if ($amount > $char_bank)
$res = die('e2');
$char_bank = $char_bank - $amount;
$char_gold = $char_gold + $amount;
save_character();
$res = $char_gold."\n".
$char_bank."\n";
}
if ($action == 'get_inn_info') {
$res = $char_gold."\n".
$char_food."\n".
$char_life_cur."\n".
$char_life_max."\n".
$char_mana_cur."\n".
$char_mana_max."\n";
}
if ($action == 'get_food') {
if ($char_gold < 10)
$res = die('e1');
if ($char_food >= 7)
$res = die('e2');
$char_gold = $char_gold - 10;
$char_food++;
save_character();
$res = $char_gold."\n".
$char_food."\n";
}
if ($action == 'get_room') {
if ($char_gold < 10)
$res = die('e1');
$char_gold = $char_gold - 10;
$char_life_cur = $char_life_max;
$char_mana_cur = $char_mana_max;
save_character();
$res = $char_gold."\n".
$char_life_max."\n".
$char_mana_max."\n";
}
if ($action == 'get_inventory') {
$res = $char_gold."\n".
$char_inv_hppotion."\n";
}
if ($action == 'get_healer_info') {
$res = $char_gold."\n".
$char_life_cur."\n".
$char_life_max."\n".
$char_mana_cur."\n".
$char_mana_max."\n";
}
if ($action == 'get_rest_info') {
$res = $char_food."\n".
$char_life_cur."\n".
$char_life_max."\n".
$char_mana_cur."\n".
$char_mana_max."\n";
}
if ($action == 'healer') {
if ($char_gold < 10)
$res = die('e1');
$char_gold = $char_gold - 10;
$char_life_cur = $char_life_max;
$char_mana_cur = $char_mana_max;
save_character();
$res = $char_gold."\n".
$char_life_max."\n".
$char_mana_max."\n";
}
if ($action == 'rest') {
if ($char_food <= 0)
$res = die('e1');
if ($char_life_cur <= 0)
$res = die('e2');
$char_life_cur = $char_life_max;
$char_mana_cur = $char_mana_max;
$char_food--;
save_character();
$res = $char_food."\n".
$char_life_max."\n".
$char_mana_max."\n";
}
if ($action == 'move_west') {
$char_x--;
save_character();
$res = $char_x."\n".
$char_y."\n";
}
if ($action == 'move_east') {
$char_x++;
save_character();
$res = $char_x."\n".
$char_y."\n";
}
if ($action == 'move_north') {
$char_y--;
save_character();
$res = $char_x."\n".
$char_y."\n";
}
if ($action == 'move_south') {
$char_y++;
save_character();
$res = $char_x."\n".
$char_y."\n";
}
if ($action == 'revive') {
$char_life_cur = rand(1, 5);
$char_mana_cur = 0;
save_character();
$res = $char_life_cur."\n".
$char_life_max."\n".
$char_mana_cur."\n".
$char_mana_max."\n";
}
if ($action == 'gen_monster') {
if ($char_monster == 0)
$char_monster = rand(1, 9);
save_character();
$res = $char_monster."\n";
}
if ($action == 'atk_monster') {
$char_monster = rand(1, 9);
$char_life_cur = $char_life_cur - rand(1, 5);
if ($char_life_cur < 0) {
$char_stat_deads = $char_stat_deads + 1;
$char_life_cur = 0;
$char_monster = 0;
$char_gold = 0;
}
if ($char_life_cur > 0) {
$char_stat_kills = $char_stat_kills + 1;
$char_gold = $char_gold + rand(5, 9);
}
save_character();
$res = $char_monster."\n".
$char_gold."\n".
$char_life_cur."\n".
$char_life_max."\n";
}

// Lizardry
if ($action == 'in_town') {
$res =
"Главная Площадь|Вы находитесь на главной площади города.".all_response()."\n";
$res = $res . "Таверна|index.php?action=tavern"."\n";
}
if ($action == 'tavern') {
$res =
"Таверна|Краткое описание таверны."."\n";
if (($char_gold >= 10)&&($char_life_cur < $char_life_max))
$res = $res . "Снять комнату на ночь|index.php?action=rest_in_tavern"."\n";
if (($char_gold >= 10)&&($char_food < 7))
$res = $res . "Купить провизию|index.php?action=buy_food_in_tavern"."\n";
$res = $res . "Покинуть Таверну|index.php?action=in_town"."\n";
}
if ($action == 'rest_in_tavern') {
if ($char_gold < 10)
$res = die(
"Таверна|У вас недостаточно золота!"."\n".
"Покинуть Таверну|index.php?action=in_town"."\n"
);
$char_gold = $char_gold - 10;
$char_life_cur = $char_life_max;
save_character();
$res =
"Таверна|Вы выспались и полны сил.".rest_response()."\n";
$res = $res . "Выйти из комнаты|index.php?action=tavern"."\n";
}
if ($action == 'buy_food_in_tavern') {
if ($char_gold < 10)
$res = die(
"Таверна|У вас недостаточно золота!"."\n".
"Покинуть Таверну|index.php?action=in_town"."\n"
);
if ($char_food < 7) {
$char_gold = $char_gold - 10;
$char_food = $char_food + 1;
save_character();
$res =
"Таверна|Вы купили один мешок провианта.".rest_response()."\n";
$res = $res . "Назад|index.php?action=tavern"."\n";
} else {
$res = "Назад|index.php?action=tavern"."\n";
}
}
}
}

echo $res;
?>
50 changes: 50 additions & 0 deletions server/lizardry/registration/registration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
$res = '0';

include '../common/common.php';

$charname = $_GET['charname'];
$action = $_GET['action'];

if ($charname == '') die('23');
if (strlen($charname) < 4) die('33');
if (strlen($charname) > 24) die('43');

if ($action == 'registration') {
if (file_exists('../characters/character.'.$username.'.php')) {
$res = '1';
} else{
$user_name = $username;
$user_pass = $userpass;
$char_name = $charname;
$char_level = 1;
$char_exp = 0;
$char_food = 7;
$char_gold = 50;
$char_bank = 10;
$char_equip_weapon = 101;
$char_equip_armor = 201;
$char_damage_min = 1;
$char_damage_max = 3;
$char_armor = 1;
$char_str = 5;
$char_dex = 5;
$char_int = 5;
$char_per = 5;
$char_life_cur = 25;
$char_life_max = 25;
$char_mana_cur = 10;
$char_mana_max = 10;
$char_inv_hppotion = 3;
$char_x = 1000;
$char_y = 1000;
$char_stat_kills = 0;
$char_stat_deads = 0;
$char_monster = 0;

save_character();
$res = '2';
}
}
echo $res;
?>
1 change: 1 addition & 0 deletions server/lizardry/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.1
Loading

0 comments on commit 2955413

Please sign in to comment.