Example #1
0
        protected void Operate( object sender, EventArgs args )
        {
            Planet planet = getPlanet();
            Result result = null;
            try {

                string operation = GetVar("currentOperation");
                string resource = GetVar("resource");
                string quantityToOperate = quantity.Text;
                quantity.Text = "";

                switch(operation) {
                    case "sell":
                        result = Chronos.Trade.Market.Sell(planet, resource, int.Parse(quantityToOperate));
                        break;
                    case "buy":
                        result = Chronos.Trade.Market.Buy(planet, resource, int.Parse(quantityToOperate));
                        break;
                    default:
                        throw new Exception();
                }

            } catch {
                result = new Result();
                result.failed( new InvalidOperation() );
            } finally {
                operationReport.ResultSet = result;
            }
        }
Example #2
0
 /// <summary>Comando de build de um recurso</summary>
 private void demolish( ResourceManager planet )
 {
     if( planet is Planet ) {
         Planet p = (Planet) planet;
         if( p.IsInBattle ) {
             Result result = new Result();
             result.failed( new PlanetInBattle() );
             QueueError.ResultSet = result;
             return;
         }
         if( p.BuilingsDemolished > 2 ) {
             Result result = new Result();
             //result.failed( new CanNotDemolish() );
             QueueError.ResultSet = result;
             return;
         }
         ++p.BuilingsDemolished;
     }
     int curr = planet.getResourceCount(Category, resource);
     if( quantity <= curr ) {
         planet.take(Category, resource, quantity);
     }
 }