public void giveExtorsionMoney(double amount, Soldiers soldier, Shop shop, Color territory) { // store money // distribute money // 50 persent for capos, then rest for solidiers System.out.println( "capo #" + this.getIndex() + "cummulatedIncome = " + cummulatedIncome + "extorsionCount = " + extorsionCount); extorsionCount++; cummulatedIncome += amount * 0.5; soldier.setMoney(soldier.getMoney() + amount * 0.5); System.out.println("capo #" + index + " has now: $" + cummulatedIncome); // draw edges between Capo and by own soldiers extorted shops Context<Object> context = ContextUtils.getContext(this); Network<Object> net = (Network<Object>) context.getProjection("network"); net.addEdge(this, shop); // sanction if money from shop from other territory if (!territory.equals(familyColor)) { // decision process --> preliminary! --- TODO: could be implemented // with EMIL-S notPermittedExtorsionCount++; double rnd = RandomHelper.nextDoubleFromTo(0.0, 1.0); if (rnd <= sanctionProbability) { soldier.sanction(shop, territory); sanctionCount++; } } // notify the mandamento if (this != mandamento.getCapo()) { mandamento.onExtortMoney(index, cummulatedIncome); } }
public void onForeignerExtorteOwnShop(int shop_index, int foreigner_capo_index, Soldiers s) { System.out.println( "[Capo #" + index + "] knowns shop #" + shop_index + " was robbed by a soldier of capo #" + foreigner_capo_index); // wait for another capo sanction // Queue<Event> & ArrayList<Event> or Queue/ Multithreads+ message // try{ // Thread.currentThread().sleep(1000); // } // catch{Exception e}; // report to Mendamento mandamento.onForeignerExtorteShop(foreigner_capo_index, s); }