Check & Edit Map Tile
'.
'New Map Tile Type:
'.
'';
return $result;
}
if(isset($_GET['do_save'])){ // update map tile type
//print_r($_POST); // Array ( [new_field_type] => 2_1 [save_x] => 29 [save_y] => 18 [x] => 0 [y] => 1 )
$new_tile_numbers = explode('_', $_POST['new_field_type']);
$new_tile_is_type = (int) $new_tile_numbers[0]; // oasis field type OR village - valley - field type
$new_tile_is_oasis_or_village = (int) $new_tile_numbers[1]; // 0 - oasis, 1 - village - valley - field
$coord_x = (int) $_POST['x'];
$coord_y = (int) $_POST['y'];
if($coord_x > WORLD_MAX){ $coord_x = WORLD_MAX; }
if($coord_x < (-WORLD_MAX)){ $coord_x = (-WORLD_MAX); }
if($coord_y > WORLD_MAX){ $coord_y = WORLD_MAX; }
if($coord_y < (-WORLD_MAX)){ $coord_y = (-WORLD_MAX); }
$row = get_map_tile_info($coord_x, $coord_y);
$is_not_oasis_tile_type = ($row['oasistype'] == 0); // not oasis but village - valley - field
if($is_not_oasis_tile_type && $row['owner_id'] && ($row['owner_id'] != 2) ){
$msg = 'Can not change map tile type for village that exists!
'; // todo add this feature as other option
}else if( ($is_not_oasis_tile_type && ($new_tile_is_oasis_or_village == 1) && ($row['fieldtype'] == $new_tile_is_type) ) ||
( (!($is_not_oasis_tile_type)) && ($new_tile_is_oasis_or_village == 0) && ($row['oasistype'] == $new_tile_is_type) ) ){ // check new tile not same as old tile
$msg = 'Can not change to the same field type!
';
}else if($is_not_oasis_tile_type && ($new_tile_is_oasis_or_village == 0) ){ // old tile was not oasis - new is oasis
upd_village_to_oasis($row['village_id'], $new_tile_is_type);
}else if( (!($is_not_oasis_tile_type)) && ($new_tile_is_oasis_or_village == 1) ){ // old tile was oasis - new is village
upd_oasis_to_village($row['village_id'], $new_tile_is_type);
}else if( (!($is_not_oasis_tile_type)) && ($new_tile_is_oasis_or_village == 0) ){ // from same to same - from oasis to oasis
upd_oasis_to_oasis($row['village_id'], $new_tile_is_type);
}else{ // from same to same - from village valley to village valley
upd_village_to_village($row['village_id'], $new_tile_is_type);
}
if($msg == ''){ $msg = 'Saved!
'; }
}else if(isset($_GET['do_get']) && isset($_POST['x']) && isset($_POST['y'])){ // get and show map tile type
$coord_x = (int) $_POST['x'];
$coord_y = (int) $_POST['y'];
if($coord_x > WORLD_MAX){ $coord_x = WORLD_MAX; }
if($coord_x < (-WORLD_MAX)){ $coord_x = (-WORLD_MAX); }
if($coord_y > WORLD_MAX){ $coord_y = WORLD_MAX; }
if($coord_y < (-WORLD_MAX)){ $coord_y = (-WORLD_MAX); }
$row = get_map_tile_info($coord_x, $coord_y);
//print_r($row);
$is_not_oasis_tile_type = ($row['oasistype'] == 0);
if($is_not_oasis_tile_type){ // not oasis map tile
$bonus_or_type = 'type: ['.$row['fieldtype'].'] '.village_type_by_fieldtype_id( $row['fieldtype'] );
if( is_null($row['owner_id']) || ($row['owner_id'] == 2) ){
$place_type = 'Abandoned Valley';
$owner = '';
//$edit_form = gen_map_tiles_select_list_form($is_ocuppied, $is_oasis, $oasistype_id, $row['fieldtype'], $coord_x, $coord_y);
$edit_form = gen_map_tiles_select_list_form(false, false, false, $row['fieldtype'], $coord_x, $coord_y);
}else{
$place_type = 'Village';
$owner = 'owner: '.$row['username'].' [id: '.$row['owner_id'].']
';
//$edit_form = gen_map_tiles_select_list_form($is_ocuppied, $is_oasis, $oasistype_id, $row['fieldtype'], $coord_x, $coord_y);
$edit_form = gen_map_tiles_select_list_form(true, false, false, $row['fieldtype'], $coord_x, $coord_y);
}
}else{ // oasis map tile
$bonus_or_type = 'bonus: ['.$row['oasistype'].'] '.oasis_type_by_id( $row['oasistype'] );
if( is_null($row['owner_id']) || ($row['owner_id'] == 2) ){ // todo check why $row['occupied'] == 0 for ocuppied oasis // todo use only owner_id / status -- not save 'Nature'/'oasis' texts in db
$place_type = 'Unocuppied oasis';
//$owner = 'owner: '.$row['username'].' [id: '.$row['owner_id'].']
'; // Nature
$owner = '';
//$edit_form = gen_map_tiles_select_list_form($is_ocuppied, $is_oasis, $row['oasistype'], $village_filedtype_id, $coord_x, $coord_y);
$edit_form = gen_map_tiles_select_list_form(false, true, $row['oasistype'], false, $coord_x, $coord_y);
}else{
$place_type = 'Occupied oasis';
$owner = 'owner: '.$row['username'].' [id: '.$row['owner_id'].']
';
//$edit_form = gen_map_tiles_select_list_form($is_ocuppied, $is_oasis, $row['oasistype'], $village_filedtype_id, $coord_x, $coord_y);
$edit_form = gen_map_tiles_select_list_form(true, true, $row['oasistype'], false, $coord_x, $coord_y);
}
}
$search_result = ''.
''.
'x: '.$coord_x.'
'.
'y: '.$coord_y.'
'.
'type: '.$place_type.'
'.
$bonus_or_type.'
'.$owner.
'
'.
'';
//}else{ // show begin search map tile form
}
echo $search_result;
?>