Changeset 548df42f8807e2be470936e582eb1072ebeed33a
- Timestamp:
- 08/05/07 22:13:18 (1 year ago)
- git-parent:
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
src/net/driftingsouls/ds2/server/modules/BaseController.java
r799695d r548df42 45 45 * @urlparam Integer col Die ID der Basis 46 46 */ 47 public class BaseController extends DSGenerator { 47 public class BaseController extends DSGenerator { 48 private static final int NAHRUNG_CHECKOUT_FACTOR = 1; 49 48 50 private Base base; 49 51 … … 96 98 Cargo usercargo = new Cargo( Cargo.Type.STRING, user.getCargo()); 97 99 98 if( (count < 0) && (-count* 100> usercargo.getResourceCount(Resources.NAHRUNG)) ) {99 count = -usercargo.getResourceCount(Resources.NAHRUNG)/ 100;100 if( (count < 0) && (-count*NAHRUNG_CHECKOUT_FACTOR > usercargo.getResourceCount(Resources.NAHRUNG)) ) { 101 count = -usercargo.getResourceCount(Resources.NAHRUNG)/NAHRUNG_CHECKOUT_FACTOR; 100 102 } 101 103 … … 111 113 112 114 cargo.substractResource( Resources.NAHRUNG, count ); 113 usercargo.addResource( Resources.NAHRUNG, count* 100);115 usercargo.addResource( Resources.NAHRUNG, count*NAHRUNG_CHECKOUT_FACTOR ); 114 116 115 117 user.setCargo(usercargo.save()); 116 118 base.setCargo(cargo); 117 119 118 t.set_var("base.message", "<img src=\""+Cargo.getResourceImage(Resources.NAHRUNG)+"\" alt=\"\" />"+Math.abs(count)+" 100er Paketetransferiert" );120 t.set_var("base.message", "<img src=\""+Cargo.getResourceImage(Resources.NAHRUNG)+"\" alt=\"\" />"+Math.abs(count)+" transferiert" ); 119 121 120 122 redirect(); … … 375 377 tooltiptext.append("<form action='./ds' method='post'>"); 376 378 tooltiptext.append("<div>"); 377 tooltiptext.append("Nahrung in 100er Paketentransferieren: <input name='nahrung' type='text' size='6' value='"+res.getCount1()+"' /><br />");379 tooltiptext.append("Nahrung transferieren: <input name='nahrung' type='text' size='6' value='"+res.getCount1()+"' /><br />"); 378 380 tooltiptext.append("<input name='col' type='hidden' value='"+base.getID()+"' />"); 379 381 tooltiptext.append("<input name='sess' type='hidden' value='"+getString("sess")+"' />"); src/net/driftingsouls/ds2/server/ships/Ship.java
rc3e8956 r548df42 833 833 String astatus = oldstatus[i]; 834 834 if( !astatus.equals("disable_iff") && !astatus.equals("mangel_nahrung") && 835 !astatus.equals("mangel_reaktor") && !astatus.equals("offizier") &&836 !astatus.equals("nocrew") && !astatus.equals("nebel") && !astatus.equals("tblmodules") ) {835 !astatus.equals("mangel_reaktor") && !astatus.equals("offizier") && 836 !astatus.equals("nocrew") && !astatus.equals("nebel") && !astatus.equals("tblmodules") ) { 837 837 status.add(astatus); 838 838 } … … 843 843 if( type.getRm() > 0 ) { 844 844 long ep = cargo.getResourceCount( Resources.URAN ) * type.getRu() + 845 cargo.getResourceCount( Resources.DEUTERIUM ) * type.getRd() +846 cargo.getResourceCount( Resources.ANTIMATERIE ) * type.getRa();845 cargo.getResourceCount( Resources.DEUTERIUM ) * type.getRd() + 846 cargo.getResourceCount( Resources.ANTIMATERIE ) * type.getRa(); 847 847 long er = ep/type.getRm(); 848 848 … … 861 861 status.add("nocrew"); 862 862 } 863 863 864 864 // Die Items nach IFF und Hydros durchsuchen 865 865 boolean disableIFF = false; 866 866 867 867 if( cargo.getItemWithEffect(ItemEffect.Type.DISABLE_IFF) != null ) { 868 868 disableIFF = true; … … 872 872 status.add("disable_iff"); 873 873 } 874 875 Cargo usercargo = new Cargo(Cargo.Type.STRING, this.owner.getCargo()); 876 877 // Den Nahrungsverbrauch berechnen 878 if( this.crew > 0 ) { 879 double scale = 1; 880 if( (this.alarm == 1) && (type.getShipClass() != ShipClasses.GESCHUETZ.ordinal()) ) { 881 scale = 0.9; 882 } 883 884 int nn = (int)Math.ceil(this.crew/scale) - type.getHydro(); 885 if( (nn > 0) || ((nn == 0) && (type.getHydro() == 0)) ) { 886 if( nn == 0 ) nn = 1; 887 long nr = usercargo.getResourceCount( Resources.NAHRUNG )/nn; 888 889 if( nr <= MANGEL_TICKS ) { 890 status.add("mangel_nahrung"); 891 } 892 } 893 } 894 874 895 875 // Ist ein Offizier an Bord? 896 876 Offizier offi = Offizier.getOffizierByDest('s', this.id); … … 898 878 status.add("offizier"); 899 879 } 900 880 901 881 ShipModules modules = (ShipModules)db.get(ShipModules.class, this.id); 902 882 if( modules != null ) { 903 883 status.add("tblmodules"); 904 884 } 885 886 if( lackOfFood() ) { 887 status.add("mangel_nahrung"); 888 } 889 890 this.status = Common.implode(" ", status); 891 892 return this.status; 893 } 894 895 private boolean lackOfFood() { 896 if( timeUntilLackOfFood() <= MANGEL_TICKS ) { 897 return true; 898 } 899 900 return false; 901 } 902 903 private long timeUntilLackOfFood() { 904 Cargo usercargo = new Cargo(Cargo.Type.STRING, this.owner.getCargo()); 905 long timeUntilLackOfFood = 0; 906 int foodConsumption = getNettoFoodConsumption(); 907 908 if( foodConsumption <= 0 ) { 909 return Long.MAX_VALUE; 910 } 911 912 //Den Nahrungsverbrauch berechnen 913 if( isUserCargoUsable() ) { 914 timeUntilLackOfFood = usercargo.getResourceCount(Resources.NAHRUNG) / foodConsumption; 915 } 916 else { 917 //Basisschiff beruecksichtigen 918 Ship baseShip = getBaseShip(); 919 if( baseShip != null ) { 920 timeUntilLackOfFood = baseShip.timeUntilLackOfFood(); 921 } 922 923 timeUntilLackOfFood += this.cargo.getResourceCount(Resources.NAHRUNG) / foodConsumption; 924 } 925 return timeUntilLackOfFood; 926 } 927 928 /** 929 * Calculates the amount of food a ship consumes. 930 * The calculation is done with respect to hydros. 931 * 932 * @return Amount of food this ship consumes 933 */ 934 private int getFoodConsumption() { 935 ShipTypeData shiptype = this.getTypeData(); 936 int scaledCrew = getScaledCrew(); 937 int production = shiptype.getHydro(); 938 return scaledCrew-production; 939 } 940 941 /** 942 * Calculates the amound of food the ship consumes with respect to docked ships. 943 * 944 * @return The amount this ship consumes with respect to docked ships. 945 */ 946 private int getNettoFoodConsumption() { 947 org.hibernate.Session db = ContextMap.getContext().getDB(); 948 int foodConsumption = getFoodConsumption(); 905 949 906 this.status = Common.implode(" ", status); 907 908 return this.status; 909 } 910 950 //Angehaengte Schiffe beruecksichtigen 951 List dockedShips = db.createQuery("from Ship as ship where ship.docked=?") 952 .setEntity(0, this) 953 .list(); 954 for( Iterator iter=dockedShips.iterator(); iter.hasNext(); ) { 955 Ship dockedShip = (Ship)iter.next(); 956 957 foodConsumption += dockedShip.getNettoFoodConsumption(); 958 } 959 return foodConsumption; 960 } 961 962 /** 963 * Returns the crew scaled by a factor according to alert red. 964 * Ships with actived alert red consume more food. 965 * 966 * @return Crew scaled by a factor according to shiptype. 967 */ 968 private int getScaledCrew() { 969 ShipTypeData type = this.getTypeData(); 970 double scale = 1; 971 if( (this.alarm == 1) && (type.getShipClass() != ShipClasses.GESCHUETZ.ordinal()) ) { 972 scale = 0.9; 973 } 974 975 int scaledCrew = (int)Math.ceil(this.crew/scale) - type.getHydro(); 976 return scaledCrew; 977 } 978 911 979 /** 912 980 * Repraesentiert ein in ein Schiff eingebautes Modul (oder vielmehr die Daten, … … 927 995 */ 928 996 public final String data; 929 997 930 998 protected ModuleEntry(int slot, int moduleType, String data) { 931 999 this.slot = slot; … … 933 1001 this.data = data; 934 1002 } 935 1003 936 1004 @Override 937 1005 public String toString() { … … 939 1007 } 940 1008 } 941 1009 942 1010 /** 943 1011 * Gibt die Moduleintraege des Schiffes zurueck … … 946 1014 public ModuleEntry[] getModules() { 947 1015 org.hibernate.Session db = ContextMap.getContext().getDB(); 948 1016 949 1017 List<Ship.ModuleEntry> result = new ArrayList<ModuleEntry>(); 950 1018 951 1019 if( this.status.indexOf("tblmodules") == -1 ) { 952 1020 return new ModuleEntry[0]; 953 1021 } 954 1022 955 1023 ShipModules moduletbl = (ShipModules)db.get(ShipModules.class, this.id); 956 1024 if( moduletbl == null ) { … … 958 1026 return new ModuleEntry[0]; 959 1027 } 960 1028 961 1029 if( moduletbl.getModules().length() != 0 ) { 962 1030 String[] modulelist = StringUtils.split(moduletbl.getModules(), ';'); … … 968 1036 } 969 1037 } 970 1038 971 1039 return result.toArray(new ModuleEntry[result.size()]); 972 1040 } 973 1041 974 1042 /** 975 1043 * Fuegt ein Modul in das Schiff ein … … 982 1050 throw new UnsupportedOperationException("addModules kann nur bei Schiffen mit positiver ID ausgefuhert werden!"); 983 1051 } 984 1052 985 1053 org.hibernate.Session db = ContextMap.getContext().getDB(); 986 1054 … … 989 1057 shipModules = new ShipModules(this.id); 990 1058 db.persist(shipModules); 991 1059 992 1060 if( this.status.length() != 0 ) { 993 1061 this.status += " tblmodules"; … … 1000 1068 shipModules = (ShipModules)db.get(ShipModules.class, this.id); 1001 1069 } 1002 1070 1003 1071 List<ModuleEntry> moduletbl = new ArrayList<ModuleEntry>(); 1004 1072 moduletbl.addAll(Arrays.asList(getModules())); 1005 1073 1006 1074 //check modules 1007 1075 1008 1076 //rebuild 1009 1077 moduletbl.add(new ModuleEntry(slot, moduleid, data )); 1010 1078 1011 1079 ShipTypeData type = Ship.getShipType( this.shiptype.getId(), false, true ); 1012 1080 1013 1081 Map<Integer,String[]>slotlist = new HashMap<Integer,String[]>(); 1014 1082 String[] tmpslotlist = StringUtils.splitPreserveAllTokens(type.getTypeModules(), ';'); … … 1017 1085 slotlist.put(Integer.parseInt(aslot[0]), aslot); 1018 1086 } 1019 1087 1020 1088 List<Module> moduleobjlist = new ArrayList<Module>(); 1021 1089 List<String> moduleSlotData = new ArrayList<String>(); 1022 1090 1023 1091 for( int i=0; i < moduletbl.size(); i++ ) { 1024 1092 ModuleEntry module = moduletbl.get(i); … … 1029 1097 } 1030 1098 moduleobjlist.add(moduleobj); 1031 1099 1032 1100 moduleSlotData.add(module.slot+":"+module.moduleType+":"+module.data); 1033 1101 } 1034 1102 } 1035 1103 1036 1104 for( int i=0; i < moduleobjlist.size(); i++ ) { 1037 1105 type = moduleobjlist.get(i).modifyStats( type, moduleobjlist ); 1038 1106 } 1039 1107 1040 1108 shipModules.setModules(Common.implode(";",moduleSlotData)); 1041 1109 shipModules.setNickname(type.getNickname()); … … 1067 1135 shipModules.setOneWayWerft(type.getOneWayWerft()); 1068 1136 } 1069 1137 1070 1138 /** 1071 1139 * Entfernt ein Modul aus dem Schiff … … 1078 1146 throw new UnsupportedOperationException("addModules kann nur bei Schiffen mit positiver ID ausgefuhert werden!"); 1079 1147 } 1080 1148 1081 1149 org.hibernate.Session db = ContextMap.getContext().getDB(); 1082 1150 1083 1151 if( this.status.indexOf("tblmodules") == -1 ) { 1084 1152 return; 1085 1153 } 1086 1154 1087 1155 ShipModules shipModules = (ShipModules)db.get(ShipModules.class, this.id); 1088 1156 1089 1157 List<ModuleEntry> moduletbl = new ArrayList<ModuleEntry>(); 1090 1158 moduletbl.addAll(Arrays.asList(getModules())); 1091 1159 1092 1160 //check modules 1093 1161 1094 1162 //rebuild 1095 1163 ShipTypeData type = Ship.getShipType( this.shiptype.getId(), false, true ); 1096 1164 1097 1165 Map<Integer,String[]>slotlist = new HashMap<Integer,String[]>(); 1098 1166 String[] tmpslotlist = StringUtils.split(type.getTypeModules(), ';'); … … 1101 1169 slotlist.put(Integer.parseInt(aslot[0]), aslot); 1102 1170 } 1103 1171 1104 1172 List<Module> moduleobjlist = new ArrayList<Module>(); 1105 1173 List<String> moduleSlotData = new ArrayList<String>(); 1106 1174 1107 1175 for( int i=0; i < moduletbl.size(); i++ ) { 1108 1176 ModuleEntry module = moduletbl.get(i); 1109 1177 if( module.moduleType != 0 ) { 1110 1178 Module moduleobj = Modules.getShipModule( module ); 1111 1179 1112 1180 if( moduleobj.isSame(slot, moduleid, data) ) { 1113 1181 continue; 1114 1182 } 1115 1183 1116 1184 if( (module.slot > 0) && (slotlist.get(module.slot).length > 2) ) { 1117 1185 moduleobj.setSlotData(slotlist.get(module.slot)[2]); 1118 1186 } 1119 1187 moduleobjlist.add(moduleobj); 1120 1188 1121 1189 moduleSlotData.add(module.slot+":"+module.moduleType+":"+module.data); 1122 1190 } … … 1126 1194 type = moduleobjlist.get(i).modifyStats( type, moduleobjlist ); 1127 1195 } 1128 1196 1129 1197 if( moduleSlotData.size() > 0 ) { 1130 1198 shipModules.setModules(Common.implode(";",moduleSlotData)); … … 1162 1230 String[] status = StringUtils.split(this.status, ' '); 1163 1231 String[] newstatus = new String[status.length-1]; 1164 1232 1165 1233 for( int i=0,j=0; i < status.length; i++ ) { 1166 1234 if( !status[i].equals("tblmodules") ) { … … 1168 1236 } 1169 1237 } 1170 1238 1171 1239 this.status = Common.implode(" ",newstatus); 1172 1240 } 1173 1241 } 1174 1242 1175 1243 /** 1176 1244 * Berechnet die durch Module verursachten Effekte des Schiffes neu … … 1178 1246 public void recalculateModules() { 1179 1247 org.hibernate.Session db = ContextMap.getContext().getDB(); 1180 1248 1181 1249 if( this.status.indexOf("tblmodules") == -1 ) { 1182 1250 return; 1183 1251 } 1184 1252 1185 1253 ShipModules shipModules = (ShipModules)db.get(ShipModules.class, this.id); 1186 1254 1187 1255 List<ModuleEntry> moduletbl = new ArrayList<ModuleEntry>(); 1188 1256 moduletbl.addAll(Arrays.asList(getModules())); 1189 1257 1190 1258 //check modules 1191 1259 1192 1260 //rebuild 1193 1261 ShipTypeData type = Ship.getShipType( this.shiptype.getId(), false, true ); 1194 1262 1195 1263 Map<Integer,String[]>slotlist = new HashMap<Integer,String[]>(); 1196 1264 String[] tmpslotlist = StringUtils.split(type.getTypeModules(), ';'); … … 1199 1267 slotlist.put(Integer.parseInt(aslot[0]), aslot); 1200 1268 } 1201 1269 1202 1270 List<Module> moduleobjlist = new ArrayList<Module>(); 1203 1271 List<String> moduleSlotData = new ArrayList<String>(); 1204 1272 1205 1273 for( int i=0; i < moduletbl.size(); i++ ) { 1206 1274 ModuleEntry module = moduletbl.get(i); 1207 1275 if( module.moduleType != 0 ) { 1208 1276 Module moduleobj = Modules.getShipModule( module ); 1209 1277 1210 1278 if( (module.slot > 0) && (slotlist.get(module.slot).length > 2) ) { 1211 1279 moduleobj.setSlotData(slotlist.get(module.slot)[2]); 1212 1280 } 1213 1281 moduleobjlist.add(moduleobj); 1214 1282 1215 1283 moduleSlotData.add(module.slot+":"+module.moduleType+":"+module.data); 1216 1284 } … … 1220 1288 type = moduleobjlist.get(i).modifyStats( type, moduleobjlist ); 1221 1289 } 1222 1290 1223 1291 shipModules.setModules(Common.implode(";",moduleSlotData)); 1224 1292 shipModules.setNickname(type.getNickname()); … … 1250 1318 shipModules.setOneWayWerft(type.getOneWayWerft()); 1251 1319 } 1252 1320 1253 1321 private void handleRedAlert() { 1254 1322 User owner = this.owner; 1255 1323 Integer[] attackers = redAlertCheck( owner, this.getLocation(), false ); 1256 1324 1257 1325 org.hibernate.Session db = ContextMap.getContext().getDB(); 1258 1326 1259 1327 if( attackers.length > 0 ) { 1260 1328 // Schauen wir mal ob wir noch ein Schiff mit rotem Alarm ohne Schlacht finden (sortiert nach Besitzer-ID) … … 1262 1330 "system=? and lock is null and docked='' and e>0 and " + 1263 1331 "owner in ("+Common.implode(",",attackers)+") and alarm=1 and " + 1264 "locate('nocrew',status)=0 and battle=0 order by owner")1265 .setInteger(0, this.x)1266 .setInteger(1, this.y)1267 .setInteger(2, this.system)1268 .setMaxResults(1)1269 .uniqueResult();1270 1332 "locate('nocrew',status)=0 and battle=0 order by owner") 1333 .setInteger(0, this.x) 1334 .setInteger(1, this.y) 1335 .setInteger(2, this.system) 1336 .setMaxResults(1) 1337 .uniqueResult(); 1338 1271 1339 if( eship != null ) { 1272 1340 Battle battle = new Battle(); 1273 1341 battle.setStartOwn(true); 1274 1342 battle.create(eship.getOwner().getID(), eship.getId(), this.id); 1275 1343 1276 1344 MESSAGE.get().append("<span style=\"color:red\">Feindliche Schiffe feuern beim Einflug</span><br />\n"); 1277 1345 } … … 1281 1349 "system=? and lock is null and docked='' and e>0 and " + 1282 1350 "owner in ("+Common.implode(",",attackers)+") and alarm=1 and " + 1283 "locate('nocrew',status)=0 and battle!=0 order by owner")1284 .setInteger(0, this.x)1285 .setInteger(1, this.y)1286 .setInteger(2, this.system)1287 .setMaxResults(1)1288 .uniqueResult();1289 1351 "locate('nocrew',status)=0 and battle!=0 order by owner") 1352 .setInteger(0, this.x) 1353 .setInteger(1, this.y) 1354 .setInteger(2, this.system) 1355 .setMaxResults(1) 1356 .uniqueResult(); 1357 1290 1358 if( eship != null ) { 1291 1359 Battle battle = new Battle(); … … 1293 1361 int oside = (bship.getSide() + 1) % 2 + 1; 1294 1362 battle.load(eship.getBattle(), this.owner.getID(), 0, 0, oside); 1295 1363 1296 1364 int docked = ((Number)db.createQuery("select count(*) from Ship where docked=?") 1297 .setString(0, Integer.toString(this.id))1298 .iterate().next()).intValue();1299 1365 .setString(0, Integer.toString(this.id)) 1366 .iterate().next()).intValue(); 1367 1300 1368 if( docked != 0 ) { 1301 1369 List dlist = db.createQuery("from Ship where docked=?") 1302 .setString(0, Integer.toString(this.id))1303 .list();1370 .setString(0, Integer.toString(this.id)) 1371 .list(); 1304 1372 for( Iterator iter=dlist.iterator(); iter.hasNext(); ) { 1305 1373 Ship aship = (Ship)iter.next(); 1306 1374 1307 1375 battle.addShip( this.owner.getID(), aship.getId() ); 1308 1376 } 1309 1377 } 1310 1378 battle.addShip( this.owner.getID(), this.id ); 1311 1379 1312 1380 if( battle.getEnemyLog(true).length() != 0 ) { 1313 1381 battle.writeLog(); 1314 1382 } 1315 1383 1316 1384 MESSAGE.get().append("<br /><span style=\"color:red\">Feindliche Schiffe feuern beim Einflug</span><br />\n"); 1317 1385 } … … 1319 1387 } 1320 1388 } 1321 1389 1322 1390 /** 1323 1391 * Gibt <code>true</code> zurueck, wenn der angegebene Sektor fuer den angegebenen Spieler … … 1331 1399 public static boolean getRedAlertStatus( int userid, int system, int x, int y ) { 1332 1400 org.hibernate.Session db = ContextMap.getContext().getDB(); 1333 1401 1334 1402 User user = (User)db.get(User.class, userid); 1335 1403 1336 1404 Integer[] attackers = redAlertCheck(user, 1337 1405 new Location(system, x, y), true); 1338 1406 1339 1407 if( attackers.length > 0 ) { 1340 1408 return true; … … 1342 1410 return false; 1343 1411 } 1344 1412 1345 1413 private static Integer[] redAlertCheck( User user, Location loc, boolean checkonly ) { 1346 1414 Context context = ContextMap.getContext(); 1347 1415 org.hibernate.Session db = context.getDB(); 1348 1416 1349 1417 User.Relations relationlist = user.getRelations(); 1350 1418 1351 1419 List<Integer> attackers = new ArrayList<Integer>(); 1352 1420 1353 1421 List ownerList = db.createQuery("select distinct s.owner from Ship as s where s.id>0 and s.x=? and s.y=? and " + 1354 "s.system=? and s.e>0 and s.owner!=? and s.alarm=1 and s.lock is null and s.docked='' and locate('nocrew',s.status)=0")1355 .setInteger(0, loc.getX())1356 .setInteger(1, loc.getY())1357 .setInteger(2, loc.getSystem())1358 .setEntity(3, user)1359 .list();1422 "s.system=? and s.e>0 and s.owner!=? and s.alarm=1 and s.lock is null and s.docked='' and locate('nocrew',s.status)=0") 1423 .setInteger(0, loc.getX()) 1424 .setInteger(1, loc.getY()) 1425 .setInteger(2, loc.getSystem()) 1426 .setEntity(3, user) 1427 .list(); 1360 1428 for( Iterator iter=ownerList.iterator(); iter.hasNext(); ) { 1361 1429 User auser = (User)iter.next(); 1362 1430 1363 1431 if( (auser.getVacationCount() != 0) && (auser.getWait4VacationCount() == 0) ) { 1364 1432 continue; 1365 1433 } 1366 1434 1367 1435 if( relationlist.fromOther.get(auser.getID()) == User.Relation.ENEMY ) { 1368 1436 attackers.add(auser.getID()); … … 1372 1440 } 1373 1441 } 1374 1442 1375 1443 return attackers.toArray(new Integer[attackers.size()]); 1376 1444 } 1377 1445 1378 1446 private static class MovementResult { 1379 1447 int distance; 1380 1448 boolean moved; 1381 1449 boolean error; 1382 1450 1383 1451 MovementResult(int distance, boolean moved, boolean error) { 1384 1452 this.distance = distance; … … 1387 1455 } 1388 1456 } 1389 1457 1390 1458 private static MovementResult moveSingle(Ship ship, ShipTypeData shiptype, Offizier offizier, int direction, int distance, int adocked, boolean forceLowHeat, boolean verbose) { 1391 1459 boolean moved = false; 1392 1460 boolean error = false; 1393 1461 boolean firstOutput = true; 1394 1462 1395 1463 StringBuilder out = MESSAGE.get(); 1396 1464 1397 1465 if( ship.getEngine() <= 0 ) { 1398 1466 if(verbose) { … … 1400 1468 } 1401 1469 distance = 0; 1402 1470 1403 1471 return new MovementResult(distance, moved, true); 1404 1472 } 1405 1473 1406 1474 int newe = ship.getEnergy() - shiptype.getCost(); 1407 1475 int news = ship.getHeat() + shiptype.getHeat(); 1408 1476 1409 1477 newe -= adocked; 1410 1478 if( shiptype.getCrew()/2 > ship.getCrew() ) { … … 1414 1482 } 1415 1483 } 1416 1484 1417 1485 // Antrieb teilweise beschaedigt? 1418 1486 if( ship.getEngine() < 20 ) { … … 1425 1493 newe -= 1; 1426 1494 } 1427 1495 1428 1496 if( newe < 0 ) { 1429 1497 if(!verbose && firstOutput) … … 1434 1502 out.append("<span style=\"color:#ff0000\">Keine Energie. Stoppe bei "+Ships.getLocationText(ship.getLocation(), true)+"</span><br />\n"); 1435 1503 distance = 0; 1436 1504 1437 1505 return new MovementResult(distance, moved, true); 1438 1506 } … … 1465 1533 } 1466 1534 } 1467 1535 1468 1536 // Grillen wir uns bei dem Flug eventuell den Antrieb? 1469 1537 if( news > 100 ) { … … 1484 1552 int x = ship.getX(); 1485 1553 int y = ship.getY(); 1486 1554 1487 1555 if( direction == 1 ) { x--; y--; } 1488 1556 else if( direction == 2 ) { y--; } … … 1493 1561 else if( direction == 8 ) { y++; } 1494 1562 else if( direction == 9 ) { x++; y++; } 1495 1563 1496 1564 StarSystem sys = Systems.get().system(ship.getSystem()); 1497 1565 1498 1566 if( x > sys.getWidth()) { 1499 1567 x = sys.getWidth(); … … 1512 1580 distance = 0; 1513 1581 } 1514 1582 1515 1583 if( (ship.getX() != x) || (ship.getY() != y) ) { 1516 1584 moved = true; 1517 1585 1518 1586 if( ship.getHeat() >= 100 ) { 1519 1587 if( !verbose && firstOutput) { … … 1522 1590 } 1523 1591 out.append("<span style=\"color:#ff0000\">Triebwerke überhitzt</span><br />\n"); 1524 1592 1525 1593 if( (RandomUtils.nextInt(101)) < 3*(news-100) ) { 1526 1594 int dmg = (int)( (2*(RandomUtils.nextInt(101)/100d)) + 1 ) * (news-100); … … 1537 1605 } 1538 1606 } 1539 1607 1540 1608 ship.setX(x); 1541 1609 s
