Skip to content

Instantly share code, notes, and snippets.

@katsube
Last active November 13, 2022 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save katsube/81277cae02c703f411588d2c750817d5 to your computer and use it in GitHub Desktop.
Save katsube/81277cae02c703f411588d2c750817d5 to your computer and use it in GitHub Desktop.
<?php
//------------------------------------
// 定数
//------------------------------------
define('LIST_NAME', 0); // MONSTER_LIST配列の「名前」の場所
define('LIST_AREA', 1); // MONSTER_LIST配列の「出現場所」の場所
define('LIST_LV', 2); // MONSTER_LIST配列の「レベル」の場所
define('LIST_HP', 3); // MONSTER_LIST配列の「HP」の場所
//------------------------------------
// グローバル変数
//------------------------------------
$MONSTER_LIST = [
// 名前, 出現エリア, レベル, HP
['スライム', '草原', 2, 10],
['ドラキー', '草原', 3, 15],
['ゴブリン', '洞窟', 3, 20],
['ドラゴン', '山', 10, 150]
];
//------------------------------------
// メイン処理
//------------------------------------
// "草原"に出没するモンスター一覧を取得
$list = findMonsterList($MONSTER_LIST, '草原');
// 表示する
for($i=0; $i<count($list); $i++){
printf("%s(Lv.%d)が現れた!\n", $list[$i][LIST_NAME], $list[$i][LIST_LV]);
}
/**
* 指定エリアに出現するモンスターの一覧を作成
*
*/
function findMonsterList($monsters, $area) {
$list = [ ];
// ★ここを回答する★
return($list);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment