//ähnlich wie reachDefense, nur schaut es, ob gegnerische Charaktere den Nachschub blockieren public Listing reachSupply(int distance, Nation nationOfGeneral) { Town tow; Listing result = new Listing(); if (distance > 0) { ListElement a = towns.head; ListElement b; Character cha; bool isEnemyInTown; while (a.next != null) { a = a.next; isEnemyInTown = true; if (!result.search(a.data)) { result.add(a.data); } if (distance > 1) { if (a.data.GetType() == typeof(Town) || a.data.GetType() == typeof(Fort)) { tow = (Town)a.data; b = tow.inTown.head; if (b.next == null) isEnemyInTown = false; while (b.next != null) { b = b.next; cha = (Character)b.data; if (cha.nation == nationOfGeneral || nationOfGeneral.allies.search(cha.nation)) isEnemyInTown = false; } if (!isEnemyInTown) result.add(tow.reachSupply(distance - 1, nationOfGeneral)); } } } } return result; }
//ähnlich wie reachSupply //reachMovePoints: Anzahl restlicher Bewegungspunkte der Einheit, Kosten: 4 für Straßen, nur 3 für Hauptstraßen public Listing reachMove(int reachMovePoints, Nation nationOfGeneral) { Town tow; Listing result = new Listing(); ListElement a = mainStreet.head; int unitType; //0:Kein Gegner, 1:ein eigener General, 2:zwei eigene Generäle, 3:drei eigene Generäle, 4:Verbündeter, 5:gegnerischer Tross, 6:gegnerischer General, negative Werte: Fehler if (reachMovePoints >= 3) //HauptstraßenTeil { while (a.next != null) { a = a.next; if (a.data.GetType() == typeof(Town) || a.data.GetType() == typeof(Fort)) { tow = (Town)a.data; unitType = tow.unitTypeInTown(nationOfGeneral); if (((unitType >= 0 && unitType <= 2) || unitType == 5) && !result.search(a.data)) //Der General darf in die Stadt laufen result.add(a.data); if (unitType == 0) result.add(tow.reachMove(reachMovePoints - 3, nationOfGeneral)); if (unitType < 0) System.Console.WriteLine("Warnung: Die reachMove Methode hatte Probleme den stationierten Einheiten in der Stadt " + tow.name + " zu finden(HauptstraßenTeil)"); } } } a = towns.head; if(reachMovePoints >= 4) //Nebenstraßenteil { while (a.next != null) { a = a.next; if ((a.data.GetType() == typeof(Town) || a.data.GetType() == typeof(Fort)) && !this.mainStreet.search(a.data)) { tow = (Town)a.data; unitType = tow.unitTypeInTown(nationOfGeneral); // System.Console.WriteLine("NebenstraßenTeil reachMove in " + this.name + " unitType der Stadt "+ tow.name+" ist " + unitType+" movePoints: "+ reachMovePoints); if (((unitType >= 0 && unitType <= 2) || unitType == 5) && !result.search(a.data)) //Der General darf in die Stadt laufen result.add(a.data); if (unitType == 0) //Wenn die Stadt leer ist, dann schaue weiter { // System.Console.WriteLine("Z476: "+tow.name+": "+t.resultString()); result.add(tow.reachMove(reachMovePoints - 4, nationOfGeneral)); } if (unitType < 0) System.Console.WriteLine("Warnung: Die reachMove Methode hatte Probleme den stationierten Einheiten in der Stadt " + tow.name + " zu finden(NebenstraßenTeil)"); } } } return result; }