| 228 | | public void create( int id, int ownShipID, int enemyShipID ) { |
|---|
| | 462 | /** |
|---|
| | 463 | * Erstellt eine neue Schlacht |
|---|
| | 464 | * @param id Die ID des Spielers, der die Schlacht beginnt |
|---|
| | 465 | * @param ownShipID Die ID des Schiffes des Spielers, der angreift |
|---|
| | 466 | * @param enemyShipID Die ID des angegriffenen Schiffes |
|---|
| | 467 | * @return <code>true</code>, falls die Schlacht erfolgreich erstellt wurde |
|---|
| | 468 | */ |
|---|
| | 469 | public boolean create( int id, int ownShipID, int enemyShipID ) { |
|---|
| | 470 | Context context = ContextMap.getContext(); |
|---|
| | 471 | Database db = context.getDatabase(); |
|---|
| | 472 | |
|---|
| | 473 | // Kann der Spieler ueberhaupt angreifen (Noob-Schutz?) |
|---|
| | 474 | User user = context.createUserObject( id ); |
|---|
| | 475 | if( user.isNoob() ) { |
|---|
| | 476 | context.addError("Sie stehen unter GCP-Schutz und können daher keinen Gegner angreifen!<br />Hinweis: der GCP-Schutz kann unter Optionen vorzeitig beendet werden"); |
|---|
| | 477 | return false; |
|---|
| | 478 | } |
|---|
| | 479 | |
|---|
| | 480 | SQLResultRow tmpOwnShip = db.first("SELECT t1.id,t1.x,t1.y,t1.system,t2.ally,t1.lock FROM ships t1 JOIN users t2 ON t1.owner=t2.id WHERE t1.id>0 AND t1.owner=",id," AND t1.id=",ownShipID); |
|---|
| | 481 | SQLResultRow tmpEnemyShip = db.first("SELECT t1.id,t1.x,t1.y,t1.system,t1.owner,t1.status,t2.ally,t1.lock FROM ships t1 JOIN users t2 ON t1.owner=t2.id WHERE t1.id>0 AND t1.id=",enemyShipID); |
|---|
| | 482 | |
|---|
| | 483 | if( tmpOwnShip.isEmpty() ) { |
|---|
| | 484 | context.addError("Das angreifende Schiff existiert nicht oder untersteht nicht ihrem Kommando!"); |
|---|
| | 485 | return false; |
|---|
| | 486 | } |
|---|
| | 487 | |
|---|
| | 488 | if( tmpEnemyShip.isEmpty() ) { |
|---|
| | 489 | context.addError("Das angegebene Zielschiff existiert nicht!"); |
|---|
| | 490 | return false; |
|---|
| | 491 | } |
|---|
| | 492 | |
|---|
| | 493 | if( !Location.fromResult(tmpOwnShip).sameSector(0,Location.fromResult(tmpEnemyShip),0) ) { |
|---|
| | 494 | context.addError("Die beiden Schiffe befinden sich nicht im selben Sektor"); |
|---|
| | 495 | return false; |
|---|
| | 496 | } |
|---|
| | 497 | |
|---|
| | 498 | // |
|---|
| | 499 | // Kann der Spieler angegriffen werden (NOOB-Schutz?/Vac-Mode?) |
|---|
| | 500 | // |
|---|
| | 501 | |
|---|
| | 502 | User enemyUser = context.createUserObject( tmpEnemyShip.getInt("owner") ); |
|---|
| | 503 | if( enemyUser.isNoob() ) { |
|---|
| | 504 | context.addError("Der Gegner steht unter GCP-Schutz und kann daher nicht angegriffen werden!"); |
|---|
| | 505 | return false; |
|---|
| | 506 | } |
|---|
| | 507 | |
|---|
| | 508 | if( enemyUser.getVacationCount() != 0 && enemyUser.getWait4VacationCount() == 0 ) { |
|---|
| | 509 | context.addError("Der Gegner befindet sich im Vacation-Modus und kann daher nicht angegriffen werden!"); |
|---|
| | 510 | return false; |
|---|
| | 511 | } |
|---|
| | 512 | |
|---|
| | 513 | // |
|---|
| | 514 | // IFF-Stoersender? |
|---|
| | 515 | // |
|---|
| | 516 | boolean disable_iff = tmpEnemyShip.getString("status").indexOf("disable_iff") > -1; |
|---|
| | 517 | if( disable_iff ) { |
|---|
| | 518 | context.addError("Dieses Schiff kann nicht angegriffen werden (egal wieviel du mit der URL rumspielt!)"); |
|---|
| | 519 | return false; |
|---|
| | 520 | } |
|---|
| | 521 | |
|---|
| | 522 | // |
|---|
| | 523 | // Questlock? |
|---|
| | 524 | // |
|---|
| | 525 | if( tmpOwnShip.getString("lock").length() > 0 ) { |
|---|
| | 526 | context.addError("Ihr Schiff ist an ein Quest gebunden"); |
|---|
| | 527 | return false; |
|---|
| | 528 | } |
|---|
| | 529 | |
|---|
| | 530 | if( tmpEnemyShip.getString("lock").length() > 0 ) { |
|---|
| | 531 | context.addError("Das gegnerische Schiff ist an ein Quest gebunden"); |
|---|
| | 532 | return false; |
|---|
| | 533 | } |
|---|
| | 534 | |
|---|
| | 535 | // |
|---|
| | 536 | // Schiffsliste zusammenstellen |
|---|
| | 537 | // |
|---|
| | 538 | |
|---|
| | 539 | this.ownSide = 0; |
|---|
| | 540 | this.enemySide = 1; |
|---|
| | 541 | |
|---|
| | 542 | SQLResultRow enemyShip = new SQLResultRow(); |
|---|
| | 543 | SQLResultRow ownShip = new SQLResultRow(); |
|---|
| | 544 | |
|---|
| | 545 | Set<Integer> ownUsers = new HashSet<Integer>(); |
|---|
| | 546 | Set<Integer> enemyUsers = new HashSet<Integer>(); |
|---|
| | 547 | |
|---|
| | 548 | SQLQuery aShipRow = db.query("SELECT t1.*,t2.name AS username,t2.ally ", |
|---|
| | 549 | "FROM ships t1 JOIN users t2 ON t1.owner=t2.id ", |
|---|
| | 550 | "WHERE t1.id>0 AND t1.x=",tmpOwnShip.getInt("x")," AND t1.y=",tmpOwnShip.getInt("y")," AND " , |
|---|
| | 551 | "t1.system=",tmpOwnShip.getInt("system")," AND t1.battle=0 AND " , |
|---|
| | 552 | "t2.ally IN (",tmpOwnShip.getInt("ally"),",",tmpEnemyShip.getInt("ally"),") AND " , |
|---|
| | 553 | "!LOCATE('disable_iff',t1.status)"); |
|---|
| | 554 | |
|---|
| | 555 | while( aShipRow.next() ) { |
|---|
| | 556 | if( (aShipRow.getString("lock") != null) && aShipRow.getString("lock").length() > 0 ) { |
|---|
| | 557 | continue; |
|---|
| | 558 | } |
|---|
| | 559 | // Loot-Truemmer sollten in keine Schlacht wandern... (nicht schoen, gar nicht schoen geloest) |
|---|
| | 560 | if( (aShipRow.getInt("owner") == -1) && (aShipRow.getInt("type") == Configuration.getIntSetting("CONFIG_TRUEMMER")) ) { |
|---|
| | 561 | continue; |
|---|
| | 562 | } |
|---|
| | 563 | |
|---|
| | 564 | User tmpUser = context.createUserObject( aShipRow.getInt("owner") ); |
|---|
| | 565 | |
|---|
| | 566 | if( ((tmpUser.getVacationCount() != 0) && (tmpUser.getWait4VacationCount() == 0)) || tmpUser.isNoob() ) { |
|---|
| | 567 | continue; |
|---|
| | 568 | } |
|---|
| | 569 | |
|---|
| | 570 | SQLResultRow aShip = aShipRow.getRow(); |
|---|
| | 571 | |
|---|
| | 572 | SQLResultRow shiptype = Ships.getShipType(aShip); |
|---|
| | 573 | if( (aShip.getString("docked").length() == 0) && Ships.hasShipTypeFlag(shiptype, Ships.SF_SECONDROW) ) { |
|---|
| | 574 | aShip.put("action", BS_SECONDROW); |
|---|
| | 575 | } |
|---|
| | 576 | else { |
|---|
| | 577 | aShip.put("action", 0); |
|---|
| | 578 | } |
|---|
| | 579 | |
|---|
| | 580 | if( (shiptype.getInt("class") == ShipClasses.GESCHUETZ.ordinal()) && aShip.getString("docked").length() > 0 ) { |
|---|
| | 581 | aShip.put("action", aShip.getInt("action") | BS_DISABLE_WEAPONS); |
|---|
| | 582 | } |
|---|
| | 583 | |
|---|
| | 584 | if( ( (tmpOwnShip.getInt("ally") > 0) && (aShip.getInt("ally") == tmpOwnShip.getInt("ally")) ) || (id == aShip.getInt("owner")) ) { |
|---|
| | 585 | ownUsers.add(aShip.getInt("owner")); |
|---|
| | 586 | if( (ownShipID != 0) && (aShip.getInt("id") == ownShipID) ) { |
|---|
| | 587 | ownShip = aShip; |
|---|
| | 588 | } |
|---|
| | 589 | else { |
|---|
| | 590 | this.ownShips.add(aShip); |
|---|
| | 591 | } |
|---|
| | 592 | } |
|---|
| | 593 | else if( ( (tmpEnemyShip.getInt("ally") > 0) && (aShip.getInt("ally") == tmpEnemyShip.getInt("ally")) ) || (tmpEnemyShip.getInt("owner") == aShip.getInt("owner")) ) { |
|---|
| | 594 | enemyUsers.add(aShip.getInt("owner")); |
|---|
| | 595 | if( (enemyShipID != 0) && (aShip.getInt("id") == enemyShipID) ) { |
|---|
| | 596 | enemyShip = aShip; |
|---|
| | 597 | } |
|---|
| | 598 | else { |
|---|
| | 599 | this.enemyShips.add(aShip); |
|---|
| | 600 | } |
|---|
| | 601 | } |
|---|
| | 602 | |
|---|
| | 603 | } |
|---|
| | 604 | aShipRow.free(); |
|---|
| | 605 | |
|---|
| | 606 | tmpOwnShip.clear(); |
|---|
| | 607 | tmpEnemyShip.clear(); |
|---|
| | 608 | |
|---|
| | 609 | // |
|---|
| | 610 | // Schauen wir mal ob wir was sinnvolles aus der DB gelesen haben |
|---|
| | 611 | // - Wenn nicht: Abbrechen |
|---|
| | 612 | // |
|---|
| | 613 | |
|---|
| | 614 | if( ownShip.isEmpty() ) { |
|---|
| | 615 | context.addError("Offenbar liegt ein Problem mit dem von ihnen angegebenen Schiff oder ihrem eigenen Schiff vor (wird es evt. bereits angegriffen?)"); |
|---|
| | 616 | return false; |
|---|
| | 617 | } |
|---|
| | 618 | |
|---|
| | 619 | if( enemyShip.isEmpty() && (enemyShips.size() == 0) ) { |
|---|
| | 620 | context.addError("Offenbar liegt ein Problem mit den feindlichen Schiffen vor (es gibt nämlich keine die sie angreifen könnten)"); |
|---|
| | 621 | return false; |
|---|
| | 622 | } |
|---|
| | 623 | else if( enemyShip.isEmpty() ) { |
|---|
| | 624 | context.addError("Offenbar liegt ein Problem mit den feindlichen Schiffen vor (es gibt zwar welche, jedoch fehlt das Zielschiff)"); |
|---|
| | 625 | return false; |
|---|
| | 626 | } |
|---|
| | 627 | |
|---|
| | 628 | // |
|---|
| | 629 | // Schlacht in die DB einfuegen |
|---|
| | 630 | // |
|---|
| | 631 | |
|---|
| | 632 | db.update("INSERT INTO battles (x,y,system,ally1,ally2,commander1,com1Points,commander2,com2Points,lastaction,lastturn,flags) ", |
|---|
| | 633 | "VALUES (",ownShip.getInt("x"),",",ownShip.getInt("y"),",",ownShip.getInt("system"),",",ownShip.getInt("ally"),",",enemyShip.getInt("ally"),", ", |
|---|
| | 634 | ownShip.getInt("owner"),",0,",enemyShip.getInt("owner"),",0,",Common.time(),",",Common.time(),",'",FLAG_FIRSTROUND,"')"); |
|---|
| | 635 | this.id = db.insertID(); |
|---|
| | 636 | |
|---|
| | 637 | if( db.affectedRows() == 0 ) { |
|---|
| | 638 | context.addError("<span style=\"color:red\">Die Schlacht konnte nicht erfolgreich erstellt werden</span>"); |
|---|
| | 639 | return false; |
|---|
| | 640 | } |
|---|
| | 641 | |
|---|
| | 642 | // |
|---|
| | 643 | // Schiffe in die Schlacht einfuegen |
|---|
| | 644 | // |
|---|
| | 645 | |
|---|
| | 646 | int tick = context.get(ContextCommon.class).getTick(); |
|---|
| | 647 | |
|---|
| | 648 | // * Gegnerische Schiffe in die Schlacht einfuegen |
|---|
| | 649 | List<Integer> idlist = new ArrayList<Integer>(); |
|---|
| | 650 | List<Integer> startlist = new ArrayList<Integer>(); |
|---|
| | 651 | |
|---|
| | 652 | if( (enemyShip.getString("docked").length() > 0) && (enemyShip.getString("docked").charAt(0) == 'l') ) { |
|---|
| | 653 | startlist.add(enemyShip.getInt("id")); |
|---|
| | 654 | } |
|---|
| | 655 | idlist.add(enemyShip.getInt("id")); |
|---|
| | 656 | |
|---|
| | 657 | SQLResultRow enemyShipType = Ships.getShipType(enemyShip); |
|---|
| | 658 | |
|---|
| | 659 | db.update("INSERT INTO battles_ships ", |
|---|
| | 660 | "(shipid,battleid,side,hull,shields,engine,weapons,comm,sensors,action,count) ", |
|---|
| | 661 | "VALUES (",enemyShip.getInt("id"),",",this.id,",1,",enemyShip.getInt("hull"),",",enemyShip.getInt("shields"),",",enemyShip.getInt("engine"),",",enemyShip.getInt("weapons"),",",enemyShip.getInt("comm"),",",enemyShip.getInt("sensors"),",",enemyShip.getInt("action"),",",enemyShipType.getInt("shipcount"),")"); |
|---|
| | 662 | |
|---|
| | 663 | |
|---|
| | 664 | for( int i=0; i < enemyShips.size(); i++ ) { |
|---|
| | 665 | SQLResultRow ship = enemyShips.get(i); |
|---|
| | 666 | |
|---|
| | 667 | if( (ship.getString("docked").length() > 0) && |
|---|
| | 668 | (ship.getString("docked").charAt(0) == 'l') ) { |
|---|
| | 669 | startlist.add(ship.getInt("id")); |
|---|
| | 670 | } |
|---|
| | 671 | idlist.add(ship.getInt("id")); |
|---|
| | 672 | |
|---|
| | 673 | SQLResultRow shiptype = Ships.getShipType(ship); |
|---|
| | 674 | |
|---|
| | 675 | db.update("INSERT INTO battles_ships ", |
|---|
| | 676 | "(shipid,battleid,side,hull,shields,engine,weapons,comm,sensors,action,count) ", |
|---|
| | 677 | "VALUES (",ship.getInt("id"),",",this.id,",1,",ship.getInt("hull"),",",ship.getInt("shields"),",",ship.getInt("engine"),",",ship.getInt("weapons"),",",ship.getInt("comm"),",",ship.getInt("sensors"),",",ship.getInt("action"),",",shiptype.getInt("shipcount"),")"); |
|---|
| | 678 | } |
|---|
| | 679 | if( startlist.size() > 0 ) { |
|---|
| | 680 | this.logme(startlist.size()+" Jäger sind automatisch gestartet\n"); |
|---|
| | 681 | this.logenemy("<action side=\"1\" time=\""+Common.time()+"\" tick=\""+tick+"\"><![CDATA[\n"+startlist.size()+" Jäger sind automatisch gestartet\n]]></action>\n"); |
|---|
| | 682 | |
|---|
| | 683 | db.update("UPDATE ships SET docked='' WHERE id>0 AND id IN ("+Common.implode(",",startlist),")"); |
|---|
| | 684 | startlist.clear(); |
|---|
| | 685 | } |
|---|
| | 686 | |
|---|
| | 687 | // * Eigene Schiffe in die Schlacht einfuegen |
|---|
| | 688 | idlist.add(ownShip.getInt("id")); |
|---|
| | 689 | |
|---|
| | 690 | SQLResultRow ownShipType = Ships.getShipType(ownShip); |
|---|
| | 691 | |
|---|
| | 692 | db.update("INSERT INTO battles_ships ", |
|---|
| | 693 | "(shipid,battleid,side,hull,shields,engine,weapons,comm,sensors,action,count) ", |
|---|
| | 694 | "VALUES (",ownShip.getInt("id"),",",this.id,",0,",ownShip.getInt("hull"),",",ownShip.getInt("shields"),",",ownShip.getInt("engine"),",",ownShip.getInt("weapons"),",",ownShip.getInt("comm"),",",ownShip.getInt("sensors"),",",ownShip.getInt("action"),",",ownShipType.getInt("shipcount"),")"); |
|---|
| | 695 | |
|---|
| | 696 | for( int i=0; i < ownShips.size(); i++ ) { |
|---|
| | 697 | SQLResultRow ship = ownShips.get(i); |
|---|
| | 698 | |
|---|
| | 699 | if( this.startOwn && (ship.getString("docked").length() > 0) && |
|---|
| | 700 | (ship.getString("docked").charAt(0) == 'l') ) { |
|---|
| | 701 | startlist.add(ship.getInt("id")); |
|---|
| | 702 | } |
|---|
| | 703 | idlist.add(ship.getInt("id")); |
|---|
| | 704 | |
|---|
| | 705 | SQLResultRow shiptype = Ships.getShipType(ship); |
|---|
| | 706 | |
|---|
| | 707 | db.update("INSERT INTO battles_ships ", |
|---|
| | 708 | "(shipid,battleid,side,hull,shields,engine,weapons,comm,sensors,action,count) ", |
|---|
| | 709 | "VALUES (",ship.getInt("id"),",",this.id,",0,",ship.getInt("hull"),",",ship.getInt("shields"),",",ship.getInt("engine"),",",ship.getInt("weapons"),",",ship.getInt("comm"),",",ship.getInt("sensors"),",",ship.getInt("action"),",",shiptype.getInt("shipcount"),")"); |
|---|
| | 710 | } |
|---|
| | 711 | if( this.startOwn && startlist.size() > 0 ) { |
|---|
| | 712 | this.logme(startlist.size()+" Jäger sind automatisch gestartet\n"); |
|---|
| | 713 | this.logenemy("<action side=\"0\" time=\""+Common.time()+"\" tick=\""+tick+"\"><![CDATA[\n"+startlist.size()+" Jäger sind automatisch gestartet\n]]></action>\n"); |
|---|
| | 714 | |
|---|
| | 715 | db.update("UPDATE ships SET docked='' WHERE id>0 AND id IN ("+Common.implode(",",startlist),")"); |
|---|
| | 716 | } |
|---|
| | 717 | startlist = null; |
|---|
| | 718 | |
|---|
| | 719 | db.update("UPDATE ships SET battle=",this.id," WHERE id>0 AND id IN (",Common.implode(",",idlist),")"); |
|---|
| | 720 | idlist = null; |
|---|
| | 721 | |
|---|
| | 722 | // |
|---|
| | 723 | // Log erstellen |
|---|
| | 724 | // |
|---|
| | 725 | |
|---|
| | 726 | try { |
|---|
| | 727 | BufferedWriter writer = new BufferedWriter(new FileWriter(Configuration.getSetting("LOXPATH")+"battles/battle_id"+this.id+".log")); |
|---|
| | 728 | writer.append("<?xml version='1.0' encoding='UTF-8'?>\n"); |
|---|
| | 729 | writer.append("<battle>\n"); |
|---|
| | 730 | writer.append("<fileinfo format=\""+LOGFORMAT+"\" />\n"); |
|---|
| | 731 | writer.append("<coords x=\""+ownShip.getInt("x")+"\" y=\""+ownShip.getInt("y")+"\" system=\""+ownShip.getInt("system")+"\" />\n"); |
|---|
| | 732 | |
|---|
| | 733 | if( ownShip.getInt("ally") > 0 ) { |
|---|
| | 734 | writer.append("<side1 commander=\""+ownShip.getInt("owner")+"\" ally=\""+ownShip.getInt("ally")+"\" />\n"); |
|---|
| | 735 | } |
|---|
| | 736 | else { |
|---|
| | 737 | writer.append("<side1 commander=\""+ownShip.getInt("owner")+"\" />\n"); |
|---|
| | 738 | } |
|---|
| | 739 | |
|---|
| | 740 | if( enemyShip.getInt("ally") > 0 ) { |
|---|
| | 741 | writer.append("<side2 commander=\""+enemyShip.getInt("owner")+"\" ally=\""+enemyShip.getInt("ally")+"\" />\n"); |
|---|
| | 742 | } |
|---|
| | 743 | else { |
|---|
| | 744 | writer.append("<side2 commander=\""+enemyShip.getInt("owner")+"\" />\n"); |
|---|
| | 745 | } |
|---|
| | 746 | |
|---|
| | 747 | writer.append("<startdate tick=\"$tick\" time=\""+Common.time()+"\" />\n"); |
|---|
| | 748 | writer.close(); |
|---|
| | 749 | |
|---|
| | 750 | if( SystemUtils.IS_OS_UNIX ) { |
|---|
| | 751 | Runtime.getRuntime().exec("chmod 0666 "+Configuration.getSetting("LOXPATH")+"battles/battle_id"+this.id+".log"); |
|---|
| | 752 | } |
|---|
| | 753 | } |
|---|
| | 754 | catch( IOException e ) { |
|---|
| | 755 | LOG.error("Konnte KS-Log fuer Schlacht "+this.id+" nicht erstellen", e); |
|---|
| | 756 | } |
|---|
| | 757 | |
|---|
| | 758 | |
|---|
| | 759 | // |
|---|
| | 760 | // Beziehungen aktuallisieren |
|---|
| | 761 | // |
|---|
| | 762 | |
|---|
| | 763 | // Zuerst schauen wir mal ob wir es mit Allys zu tun haben und |
|---|
| | 764 | // berechnen ggf die Userlisten neu |
|---|
| | 765 | Set<Integer> calcedallys = new HashSet<Integer>(); |
|---|
| | 766 | |
|---|
| | 767 | for( Integer auserID : ownUsers ) { |
|---|
| | 768 | User auser = context.createUserObject(auserID); |
|---|
| | 769 | |
|---|
| | 770 | if( (auser.getAlly() != 0) && calcedallys.contains(auser.getAlly()) ) { |
|---|
| | 771 | SQLQuery allyuser = db.query("SELECT id FROM users WHERE ally=",auser.getAlly()," AND !(id IN (",Common.implode(",",ownUsers),"))"); |
|---|
| | 772 | while( allyuser.next() ) { |
|---|
| | 773 | ownUsers.add(allyuser.getInt("id")); |
|---|
| | 774 | } |
|---|
| | 775 | calcedallys.add(auser.getAlly()); |
|---|
| | 776 | } |
|---|
| | 777 | } |
|---|
| | 778 | |
|---|
| | 779 | for( Integer auserID : enemyUsers ) { |
|---|
| | 780 | User auser = context.createUserObject(auserID); |
|---|
| | 781 | |
|---|
| | 782 | if( (auser.getAlly() != 0) && calcedallys.contains(auser.getAlly()) ) { |
|---|
| | 783 | SQLQuery allyuser = db.query("SELECT id FROM users WHERE ally=",auser.getAlly()," AND !(id IN (",Common.implode(",",enemyUsers),"))"); |
|---|
| | 784 | while( allyuser.next() ) { |
|---|
| | 785 | enemyUsers.add(allyuser.getInt("id")); |
|---|
| | 786 | } |
|---|
| | 787 | calcedallys.add(auser.getAlly()); |
|---|
| | 788 | } |
|---|
| | 789 | } |
|---|
| | 790 | calcedallys = null; |
|---|
| | 791 | |
|---|
| | 792 | for( Integer auserID : ownUsers ) { |
|---|
| | 793 | User auser = context.createUserObject(auserID); |
|---|
| | 794 | |
|---|
| | 795 | for( Integer euserID : enemyUsers ) { |
|---|
| | 796 | User euser = context.createUserObject(euserID); |
|---|
| | 797 | |
|---|
| | 798 | auser.setRelation(euser.getID(), User.Relation.ENEMY); |
|---|
| | 799 | euser.setRelation(auser.getID(), User.Relation.ENEMY); |
|---|
| | 800 | } |
|---|
| | 801 | } |
|---|
| | 802 | |
|---|
| | 803 | // |
|---|
| | 804 | // APs berechnen |
|---|
| | 805 | // |
|---|
| | 806 | |
|---|
| | 807 | |
|---|
| | 808 | // Zuerst berechnen wir die eigenen AP |
|---|
| | 809 | int ownPoints = this.getActionPoints(this.ownSide); |
|---|
| | 810 | |
|---|
| | 811 | // Nun berechnen wir die gegnerischen AP |
|---|
| | 812 | int enemyPoints = this.getActionPoints(this.enemySide); |
|---|
| | 813 | |
|---|
| | 814 | db.update("UPDATE battles SET com1Points=",ownPoints,",com2Points=",enemyPoints," WHERE id=",this.id); |
|---|
| | 815 | |
|---|
| | 816 | return true; |
|---|
| | 817 | } |
|---|
| | 818 | |
|---|
| | 819 | //--------------------------------------------------------------------- |
|---|
| | 820 | // |
|---|
| | 821 | // addShip - Ein Schiff oder eine Flotte zu der Schlacht hinzufuegen |
|---|
| | 822 | // |
|---|
| | 823 | //--------------------------------------------------------------------- |
|---|
| | 824 | |
|---|
| | 825 | public boolean addShip( int id, int shipid ) { |
|---|
| | 826 | return addShip(id, shipid, -1); |
|---|
| | 827 | } |
|---|
| | 828 | |
|---|
| | 829 | public boolean addShip( int id, int shipid, int forceside ) { |
|---|