| | 965 | * Zeigt die Postenliste der Allianz an |
|---|
| | 966 | * |
|---|
| | 967 | * @urlparam Integer destpos Offset fuer die Liste der zerstoerten Schiffe |
|---|
| | 968 | * @urlparam Integer lostpos Offset fuer die Liste der verlorenen Schiffe |
|---|
| | 969 | */ |
|---|
| | 970 | @Action(ActionType.DEFAULT) |
|---|
| | 971 | public void showPostenAction() { |
|---|
| | 972 | if( this.ally == null ) { |
|---|
| | 973 | this.redirect("defaultNoAlly"); |
|---|
| | 974 | return; |
|---|
| | 975 | } |
|---|
| | 976 | |
|---|
| | 977 | TemplateEngine t = getTemplateEngine(); |
|---|
| | 978 | org.hibernate.Session db = getDB(); |
|---|
| | 979 | |
|---|
| | 980 | List<User> allymember = new ArrayList<User>(); |
|---|
| | 981 | List memberList = db.createQuery("from User where ally=?") |
|---|
| | 982 | .setEntity(0, this.ally) |
|---|
| | 983 | .list(); |
|---|
| | 984 | for( Iterator iter=memberList.iterator(); iter.hasNext(); ) { |
|---|
| | 985 | allymember.add((User)iter.next()); |
|---|
| | 986 | } |
|---|
| | 987 | |
|---|
| | 988 | long postencount = (Long)db.createQuery("select count(*) from AllyPosten where ally="+this.ally.getId()).iterate().next(); |
|---|
| | 989 | |
|---|
| | 990 | int membercount = allymember.size(); |
|---|
| | 991 | int maxposten = (int)Math.round(membercount*MAX_POSTENCOUNT); |
|---|
| | 992 | if( maxposten < 2 ) { |
|---|
| | 993 | maxposten = 2; |
|---|
| | 994 | } |
|---|
| | 995 | |
|---|
| | 996 | t.setVar( "show.posten", 1, |
|---|
| | 997 | "show.posten.count", postencount, |
|---|
| | 998 | "show.posten.maxcount", maxposten, |
|---|
| | 999 | "show.posten.addposten", (maxposten > postencount), |
|---|
| | 1000 | "show.posten.modify.list", "" ); |
|---|
| | 1001 | |
|---|
| | 1002 | t.setBlock( "_ALLY", "show.posten.modify.listitem", "show.posten.modify.list" ); |
|---|
| | 1003 | t.setBlock( "show.posten.modify.listitem", "show.posten.modify.userlist.listitem", "show.posten.modify.userlist.list" ); |
|---|
| | 1004 | |
|---|
| | 1005 | List<AllyPosten> posten = getContext().query("from AllyPosten as ap left join fetch ap.user where ap.ally="+this.ally.getId(), AllyPosten.class); |
|---|
| | 1006 | for( AllyPosten aposten : posten ) { |
|---|
| | 1007 | t.setVar( "show.posten.modify.name", Common._plaintitle(aposten.getName()), |
|---|
| | 1008 | "show.posten.modify.id", aposten.getId(), |
|---|
| | 1009 | "show.posten.modify.userlist.list", "" ); |
|---|
| | 1010 | |
|---|
| | 1011 | if( aposten.getUser() == null ) { |
|---|
| | 1012 | t.setVar( "show.posten.modify.userlist.id", "", |
|---|
| | 1013 | "show.posten.modify.userlist.name", "KEINER", |
|---|
| | 1014 | "show.posten.modify.userlist.selected", 1 ); |
|---|
| | 1015 | |
|---|
| | 1016 | t.parse( "show.posten.modify.userlist.list", "show.posten.modify.userlist.listitem", true ); |
|---|
| | 1017 | } |
|---|
| | 1018 | |
|---|
| | 1019 | for( int i=0; i < allymember.size(); i++ ) { |
|---|
| | 1020 | User member = allymember.get(i); |
|---|
| | 1021 | t.setVar( "show.posten.modify.userlist.id", member.getID(), |
|---|
| | 1022 | "show.posten.modify.userlist.name", Common._title(member.getNickname()), |
|---|
| | 1023 | "show.posten.modify.userlist.selected", aposten.getUser() != null && (aposten.getUser().getID() == member.getID()) ); |
|---|
| | 1024 | |
|---|
| | 1025 | t.parse( "show.posten.modify.userlist.list", "show.posten.modify.userlist.listitem", true ); |
|---|
| | 1026 | } |
|---|
| | 1027 | |
|---|
| | 1028 | t.parse( "show.posten.modify.list", "show.posten.modify.listitem", true ); |
|---|
| | 1029 | } |
|---|
| | 1030 | |
|---|
| | 1031 | if( maxposten > postencount ) { |
|---|
| | 1032 | t.setBlock( "_ALLY", "show.posten.addposten.userlist.listitem", "show.posten.addposten.userlist.list" ); |
|---|
| | 1033 | |
|---|
| | 1034 | for( int i=0; i < allymember.size(); i++ ) { |
|---|
| | 1035 | User member = allymember.get(i); |
|---|
| | 1036 | t.setVar( "show.posten.addposten.userlist.id", member.getID(), |
|---|
| | 1037 | "show.posten.addposten.userlist.name", Common._title(member.getNickname()) ); |
|---|
| | 1038 | |
|---|
| | 1039 | t.parse( "show.posten.addposten.userlist.list", "show.posten.addposten.userlist.listitem", true ); |
|---|
| | 1040 | } |
|---|
| | 1041 | } |
|---|
| | 1042 | } |
|---|
| | 1043 | |
|---|
| | 1044 | /** |
|---|
| | 1045 | * Zeigt die Liste der zerstoerten und verlorenen Schiffe der Allianz |
|---|
| | 1046 | * |
|---|
| | 1047 | * @urlparam Integer destpos Offset fuer die Liste der zerstoerten Schiffe |
|---|
| | 1048 | * @urlparam Integer lostpos Offset fuer die Liste der verlorenen Schiffe |
|---|
| | 1049 | */ |
|---|
| | 1050 | @Action(ActionType.DEFAULT) |
|---|
| | 1051 | public void showBattlesAction() { |
|---|
| | 1052 | if( this.ally == null ) { |
|---|
| | 1053 | this.redirect("defaultNoAlly"); |
|---|
| | 1054 | return; |
|---|
| | 1055 | } |
|---|
| | 1056 | |
|---|
| | 1057 | TemplateEngine t = getTemplateEngine(); |
|---|
| | 1058 | org.hibernate.Session db = getDB(); |
|---|
| | 1059 | |
|---|
| | 1060 | ///////////////////////////// |
|---|
| | 1061 | // Zerstoerte Schiffe |
|---|
| | 1062 | ///////////////////////////// |
|---|
| | 1063 | |
|---|
| | 1064 | int counter = 0; |
|---|
| | 1065 | |
|---|
| | 1066 | this.parameterNumber("destpos"); |
|---|
| | 1067 | long destpos = getInteger("destpos"); |
|---|
| | 1068 | |
|---|
| | 1069 | long destcount = (Long)db.createQuery("select count(*) from ShipLost where destAlly=?") |
|---|
| | 1070 | .setInteger(0, this.ally.getId()) |
|---|
| | 1071 | .iterate().next(); |
|---|
| | 1072 | if( destpos > destcount ) { |
|---|
| | 1073 | destpos = destcount - 10; |
|---|
| | 1074 | } |
|---|
| | 1075 | |
|---|
| | 1076 | if( destpos < 0 ) { |
|---|
| | 1077 | destpos = 0; |
|---|
| | 1078 | } |
|---|
| | 1079 | |
|---|
| | 1080 | t.setBlock( "_ALLY", "show.destships.listitem", "show.destships.list" ); |
|---|
| | 1081 | t.setBlock( "_ALLY", "show.destships.linefiller.listitem", "show.destships.linefiller.list" ); |
|---|
| | 1082 | t.setBlock( "_ALLY", "show.lostships.listitem", "show.lostships.list" ); |
|---|
| | 1083 | t.setBlock( "_ALLY", "show.lostships.linefiller.listitem", "show.lostships.linefiller.list" ); |
|---|
| | 1084 | |
|---|
| | 1085 | t.setVar( "show.battles", 1, |
|---|
| | 1086 | "show.destships.list", "", |
|---|
| | 1087 | "show.destships.linefiller.list", "", |
|---|
| | 1088 | "show.lostships.list", "", |
|---|
| | 1089 | "show.lostships.linefiller.list", "", |
|---|
| | 1090 | "show.destpos.back", destpos-10, |
|---|
| | 1091 | "show.destpos.forward", destpos+10 ); |
|---|
| | 1092 | |
|---|
| | 1093 | List sList = db.createQuery("from ShipLost where destAlly=? order by time desc") |
|---|
| | 1094 | .setInteger(0, this.ally.getId()) |
|---|
| | 1095 | .setMaxResults(10) |
|---|
| | 1096 | .setFirstResult((int)destpos) |
|---|
| | 1097 | .list(); |
|---|
| | 1098 | for( Iterator iter=sList.iterator(); iter.hasNext(); ) { |
|---|
| | 1099 | ShipLost s = (ShipLost)iter.next(); |
|---|
| | 1100 | ShipTypeData shiptype = Ship.getShipType( s.getType() ); |
|---|
| | 1101 | |
|---|
| | 1102 | counter++; |
|---|
| | 1103 | |
|---|
| | 1104 | User auser = (User)getContext().getDB().get(User.class, s.getOwner()); |
|---|
| | 1105 | String ownername = null; |
|---|
| | 1106 | if( auser != null ) { |
|---|
| | 1107 | ownername = auser.getName(); |
|---|
| | 1108 | } |
|---|
| | 1109 | else { |
|---|
| | 1110 | ownername = "Unbekannter Spieler ("+s.getOwner()+")"; |
|---|
| | 1111 | } |
|---|
| | 1112 | |
|---|
| | 1113 | t.setVar( "show.destships.name", s.getName(), |
|---|
| | 1114 | "show.destships.type.name", shiptype.getNickname(), |
|---|
| | 1115 | "show.destships.type", s.getType(), |
|---|
| | 1116 | "show.destships.type.picture", shiptype.getPicture(), |
|---|
| | 1117 | "show.destships.owner", Common._title(ownername), |
|---|
| | 1118 | "show.destships.time", Common.date("d.m.Y H:i:s",s.getTime()), |
|---|
| | 1119 | "show.destships.newrow", (counter % 5) == 0 ); |
|---|
| | 1120 | |
|---|
| | 1121 | t.parse( "show.destships.list", "show.destships.listitem", true ); |
|---|
| | 1122 | } |
|---|
| | 1123 | |
|---|
| | 1124 | while( counter % 5 != 0 ) { |
|---|
| | 1125 | t.parse( "show.destships.linefiller.list", "show.destships.linefiller.listitem", true ); |
|---|
| | 1126 | counter++; |
|---|
| | 1127 | } |
|---|
| | 1128 | |
|---|
| | 1129 | ///////////////////////////// |
|---|
| | 1130 | // Verlorene Schiffe |
|---|
| | 1131 | ///////////////////////////// |
|---|
| | 1132 | |
|---|
| | 1133 | counter = 0; |
|---|
| | 1134 | |
|---|
| | 1135 | parameterNumber("lostpos"); |
|---|
| | 1136 | long lostpos = getInteger("lostpos"); |
|---|
| | 1137 | |
|---|
| | 1138 | long lostcount = (Long)db.createQuery("select count(*) from ShipLost where ally=?") |
|---|
| | 1139 | .setInteger(0, this.ally.getId()) |
|---|
| | 1140 | .iterate().next(); |
|---|
| | 1141 | if( lostpos > lostcount ) { |
|---|
| | 1142 | lostpos = lostcount - 10; |
|---|
| | 1143 | } |
|---|
| | 1144 | |
|---|
| | 1145 | if( lostpos < 0 ) { |
|---|
| | 1146 | lostpos = 0; |
|---|
| | 1147 | } |
|---|
| | 1148 | |
|---|
| | 1149 | t.setVar( "show.lostpos.back", lostpos-10, |
|---|
| | 1150 | "show.lostpos.forward", lostpos+10 ); |
|---|
| | 1151 | |
|---|
| | 1152 | sList = db.createQuery("from ShipLost where destally=? order by time desc") |
|---|
| | 1153 | .setInteger(0, this.ally.getId()) |
|---|
| | 1154 | .setMaxResults(10) |
|---|
| | 1155 | .setFirstResult((int)lostpos) |
|---|
| | 1156 | .list(); |
|---|
| | 1157 | for( Iterator iter=sList.iterator(); iter.hasNext(); ) { |
|---|
| | 1158 | ShipLost s = (ShipLost)iter.next(); |
|---|
| | 1159 | ShipTypeData shiptype = Ship.getShipType( s.getType() ); |
|---|
| | 1160 | |
|---|
| | 1161 | counter++; |
|---|
| | 1162 | |
|---|
| | 1163 | User destowner = (User)getContext().getDB().get(User.class, s.getDestOwner()); |
|---|
| | 1164 | User owner = (User)getContext().getDB().get(User.class, s.getOwner()); |
|---|
| | 1165 | |
|---|
| | 1166 | String ownername = null; |
|---|
| | 1167 | if( owner != null ) { |
|---|
| | 1168 | ownername = owner.getName(); |
|---|
| | 1169 | } |
|---|
| | 1170 | else { |
|---|
| | 1171 | ownername = "Unbekannter Spieler ("+s.getOwner()+")"; |
|---|
| | 1172 | } |
|---|
| | 1173 | |
|---|
| | 1174 | String destownername = null; |
|---|
| | 1175 | if( destowner != null ) { |
|---|
| | 1176 | destownername = destowner.getName(); |
|---|
| | 1177 | } |
|---|
| | 1178 | else { |
|---|
| | 1179 | destownername = "Unbekannter Spieler ("+s.getDestOwner()+")"; |
|---|
| | 1180 | } |
|---|
| | 1181 | |
|---|
| | 1182 | t.setVar( "show.lostships.name", s.getName(), |
|---|
| | 1183 | "show.lostships.type.name", shiptype.getNickname(), |
|---|
| | 1184 | "show.lostships.type", s.getType(), |
|---|
| | 1185 | "show.lostships.type.picture", shiptype.getPicture(), |
|---|
| | 1186 | "show.lostships.owner", Common._title(destownername), |
|---|
| | 1187 | "show.lostships.destroyer", Common._title(ownername), |
|---|
| | 1188 | "show.lostships.time", Common.date("d.m.Y H:i:s",s.getTime()), |
|---|
| | 1189 | "show.lostships.newrow", (counter % 5) == 0 ); |
|---|
| | 1190 | |
|---|
| | 1191 | t.parse( "show.lostships.list", "show.lostships.listitem", true ); |
|---|
| | 1192 | } |
|---|
| | 1193 | |
|---|
| | 1194 | while( counter % 5 != 0 ) { |
|---|
| | 1195 | t.parse( "show.lostships.linefiller.list", "show.lostships.linefiller.listitem", true ); |
|---|
| | 1196 | counter++; |
|---|
| | 1197 | } |
|---|
| | 1198 | } |
|---|
| | 1199 | |
|---|
| | 1200 | /** |
|---|
| | 1201 | * Zeigt die Allianzeinstellungen an |
|---|
| | 1202 | * |
|---|
| | 1203 | */ |
|---|
| | 1204 | @Action(ActionType.DEFAULT) |
|---|
| | 1205 | public void showAllySettingsAction() { |
|---|
| | 1206 | if( this.ally == null ) { |
|---|
| | 1207 | this.redirect("defaultNoAlly"); |
|---|
| | 1208 | return; |
|---|
| | 1209 | } |
|---|
| | 1210 | |
|---|
| | 1211 | User user = (User)getUser(); |
|---|
| | 1212 | |
|---|
| | 1213 | if( user.getID() != this.ally.getPresident().getID() ) { |
|---|
| | 1214 | redirect(); |
|---|
| | 1215 | return; |
|---|
| | 1216 | } |
|---|
| | 1217 | |
|---|
| | 1218 | TemplateEngine t = getTemplateEngine(); |
|---|
| | 1219 | org.hibernate.Session db = getDB(); |
|---|
| | 1220 | |
|---|
| | 1221 | t.setVar( "show.einstellungen", 1, |
|---|
| | 1222 | "ally.plainname", this.ally.getName(), |
|---|
| | 1223 | "ally.description", this.ally.getDescription(), |
|---|
| | 1224 | "ally.hp", this.ally.getHp(), |
|---|
| | 1225 | "ally.allytag", this.ally.getAllyTag(), |
|---|
| | 1226 | "ally.pname", this.ally.getPname(), |
|---|
| | 1227 | "ally.showastis", this.ally.getShowAstis(), |
|---|
| | 1228 | "ally.showgtubieter", this.ally.getShowGtuBieter(), |
|---|
| | 1229 | "ally.showlrs", this.ally.getShowLrs(), |
|---|
| | 1230 | "show.einstellungen.channels.list", "" ); |
|---|
| | 1231 | |
|---|
| | 1232 | // Zuerst alle vorhandenen Channels dieser Allianz auslesen (max 2) |
|---|
| | 1233 | List<ComNetChannel> channels = new ArrayList<ComNetChannel>(); |
|---|
| | 1234 | List channelList = db.createQuery("from ComNetChannel where allyOwner=?") |
|---|
| | 1235 | .setInteger(0, this.ally.getId()) |
|---|
| | 1236 | .setMaxResults(2) |
|---|
| | 1237 | .list(); |
|---|
| | 1238 | for( Iterator iter=channelList.iterator(); iter.hasNext(); ) { |
|---|
| | 1239 | channels.add((ComNetChannel)iter.next()); |
|---|
| | 1240 | } |
|---|
| | 1241 | channels.add(null); |
|---|
| | 1242 | |
|---|
| | 1243 | t.setBlock( "_ALLY", "show.einstellungen.channels.listitem", "show.einstellungen.channels.list" ); |
|---|
| | 1244 | |
|---|
| | 1245 | // Nun die vorhandenen Channels anzeigen und ggf. eine Eingabemaske fuer neue Channels anzeigen |
|---|
| | 1246 | for( int i=0; i<=1; i++ ) { |
|---|
| | 1247 | t.start_record(); |
|---|
| | 1248 | t.setVar( "show.einstellungen.channels.id", channels.get(i) == null ? 0 : channels.get(i).getId(), |
|---|
| | 1249 | "show.einstellungen.channels.index", i+1 ); |
|---|
| | 1250 | |
|---|
| | 1251 | if( channels.get(i) != null ) { |
|---|
| | 1252 | t.setVar( "show.einstellungen.channels.name", Common._plaintitle(channels.get(i).getName()), |
|---|
| | 1253 | "show.einstellungen.channels.readall", channels.get(i).isReadAll(), |
|---|
| | 1254 | "show.einstellungen.channels.writeall", channels.get(i).isWriteAll(), |
|---|
| | 1255 | "show.einstellungen.channels.readally", channels.get(i).getReadAlly(), |
|---|
| | 1256 | "show.einstellungen.channels.writeally", channels.get(i).getWriteAlly(), |
|---|
| | 1257 | "show.einstellungen.channels.readids", channels.get(i).getReadPlayer(), |
|---|
| | 1258 | "show.einstellungen.channels.writeids", channels.get(i).getWritePlayer() ); |
|---|
| | 1259 | } |
|---|
| | 1260 | else { |
|---|
| | 1261 | t.setVar( "show.einstellungen.channels.name", "", |
|---|
| | 1262 | "show.einstellungen.channels.readall", 1, |
|---|
| | 1263 | "show.einstellungen.channels.writeall", 1 ); |
|---|
| | 1264 | } |
|---|
| | 1265 | |
|---|
| | 1266 | t.parse( "show.einstellungen.channels.list", "show.einstellungen.channels.listitem", true ); |
|---|
| | 1267 | |
|---|
| | 1268 | t.stop_record(); |
|---|
| | 1269 | t.clear_record(); |
|---|
| | 1270 | |
|---|
| | 1271 | // Maximal eine Eingabemaske anzeigen |
|---|
| | 1272 | if( channels.get(i) == null ) { |
|---|
| | 1273 | break; |
|---|
| | 1274 | } |
|---|
| | 1275 | } |
|---|
| | 1276 | } |
|---|
| | 1277 | |
|---|
| | 1278 | /** |
|---|
| | 1279 | * Zeigt die Mitgliederliste an |
|---|
| | 1280 | * |
|---|
| | 1281 | */ |
|---|
| | 1282 | @Action(ActionType.DEFAULT) |
|---|
| | 1283 | public void showMembersAction() { |
|---|
| | 1284 | if( this.ally == null ) { |
|---|
| | 1285 | this.redirect("defaultNoAlly"); |
|---|
| | 1286 | return; |
|---|
| | 1287 | } |
|---|
| | 1288 | |
|---|
| | 1289 | User user = (User)getUser(); |
|---|
| | 1290 | TemplateEngine t = getTemplateEngine(); |
|---|
| | 1291 | org.hibernate.Session db = getDB(); |
|---|
| | 1292 | |
|---|
| | 1293 | t.setVar( "show.members", 1, |
|---|
| | 1294 | "user.president", (user.getID() == this.ally.getPresident().getID()) ); |
|---|
| | 1295 | |
|---|
| | 1296 | t.setBlock( "_ALLY", "show.members.listitem", "show.members.list" ); |
|---|
| | 1297 | |
|---|
| | 1298 | //Mitglieder auflisten |
|---|
| | 1299 | List memberList = db.createQuery("from User where ally=? order by name") |
|---|
| | 1300 | .setEntity(0, this.ally) |
|---|
| | 1301 | .list(); |
|---|
| | 1302 | for( Iterator iter=memberList.iterator(); iter.hasNext(); ) { |
|---|
| | 1303 | User member = (User)iter.next(); |
|---|
| | 1304 | |
|---|
| | 1305 | t.setVar( "show.members.name", Common._title( member.getName() ), |
|---|
| | 1306 | "show.members.id", member.getID() ); |
|---|
| | 1307 | |
|---|
| | 1308 | if( user.getID() == this.ally.getPresident().getID() ) { |
|---|
| | 1309 | String inakt_status = ""; |
|---|
| | 1310 | int inakt = member.getInactivity(); |
|---|
| | 1311 | if( inakt <= 14 ) { |
|---|
| | 1312 | inakt_status = "<span style=\\'color:#00FF00\\'>aktiv</span>"; |
|---|
| | 1313 | } |
|---|
| | 1314 | else if( inakt <= 49 ) { |
|---|
| | 1315 | inakt_status = "<span style=\\'color:#22AA22\\'>weniger aktiv</span>"; |
|---|
| | 1316 | } |
|---|
| | 1317 | else if( inakt <= 98 ) { |
|---|
| | 1318 | inakt_status = "<span style=\\'color:#668822\\'>selten aktiv</span>"; |
|---|
| | 1319 | } |
|---|
| | 1320 | else if( inakt <= 196 ) { |
|---|
| | 1321 | inakt_status = "<span style=\\'color:#884422\\'>inaktiv</span>"; |
|---|
| | 1322 | } |
|---|
| | 1323 | else if( inakt <= 300 ) { |
|---|
| | 1324 | inakt_status = "<span style=\\'color:#AA4422\\'>scheintot</span>"; |
|---|
| | 1325 | } |
|---|
| | 1326 | else { |
|---|
| | 1327 | inakt_status = "<span style=\\'color:#FF2222\\'>bald gelöscht</span>"; |
|---|
| | 1328 | } |
|---|
| | 1329 | |
|---|
| | 1330 | |
|---|