diff --git a/Admin/Templates/map_tile.tpl b/Admin/Templates/map_tile.tpl new file mode 100644 index 00000000..8d7d31a2 --- /dev/null +++ b/Admin/Templates/map_tile.tpl @@ -0,0 +1,335 @@ +

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; +?> + + + +
+ +
+ x + y + +

+ +
+ +
\ No newline at end of file diff --git a/Admin/admin.php b/Admin/admin.php index e73fe9f4..77c03fed 100644 --- a/Admin/admin.php +++ b/Admin/admin.php @@ -30,6 +30,7 @@ include('Templates/update_latest.tpl'); $up_avl = $latest - $ver ; $subpage = 'Login'; +$not_include_mootools_js = false; if (!empty($_GET['p'])) { switch ($_GET['p']) { @@ -60,7 +61,12 @@ if (!empty($_GET['p'])) { case 'map': $subpage = 'Map'; break; - + + case 'map_tile': + $subpage = 'Map Tile'; + $not_include_mootools_js = true; + break; + case 'natars': $subpage = 'Natars Management'; break; @@ -353,9 +359,15 @@ if (!empty($_GET['p'])) { + + @@ -506,6 +518,7 @@ if (!empty($_GET['p'])) {
  • Players Report
  • Players Message
  • Map
  • +
  • Map Tile
  • Natars Management
  • diff --git a/css/admin_map_tile.css b/css/admin_map_tile.css new file mode 100644 index 00000000..c28afd1b --- /dev/null +++ b/css/admin_map_tile.css @@ -0,0 +1,32 @@ +/* reset sime game map css for display in admin panel */ + +div.map{ +padding:0; +width:74px +} + +div.map div#map{ +height:74px; +top:0; +width:74px +} + +div.map div#map div#map_content{ +background:none; +height:74px; +left:0; +top:0; +width:74px +} + +div#map_coords form input#btn_ok{ +position:relative; +top:6px +} + +div#map_coords form input#btn_save{ +display:inline-block; +position:relative; +top:4px; +left:5px +}