Пример #1
0
        public async Task <IActionResult> Book(int id)
        {
            _log4net.Info("Booking in progess");
            if (HttpContext.Session.GetString("token") == null)
            {
                return(RedirectToAction("Login", "Login"));
            }
            else
            {
                Pg   Item = new Pg();
                Book b    = new Book();
                using (var client = new HttpClient())
                {
                    var contentType = new MediaTypeWithQualityHeaderValue("application/json");
                    client.DefaultRequestHeaders.Accept.Add(contentType);

                    client.DefaultRequestHeaders.Authorization =
                        new AuthenticationHeaderValue("Bearer", HttpContext.Session.GetString("token"));

                    using (var response = await client.GetAsync("https://localhost:44345/api/Pg/" + id))
                    {
                        string apiResponse = await response.Content.ReadAsStringAsync();

                        Item = JsonConvert.DeserializeObject <Pg>(apiResponse);
                    }
                    b.pg_Id       = Item.pg_id;
                    b.UserId      = Convert.ToInt32(HttpContext.Session.GetInt32("Userid"));
                    b.BookingDate = DateTime.Now;
                    b.No_ofMonth  = 0;
                    b.TotalCost   = 0;
                }
                return(View(b));
            }
        }
Пример #2
0
        public void Interact()
        {
            Block temp = Pg.GetBlockPosition(Map.GetMapSet());

            if (temp is UnlockableBlock)
            {
                if (Pg.GetMoney() >= UnlockPrice)
                {
                    interaction.UnlockBlock(Pg, Map, temp);
                    Pg.DecreaseMoney(UnlockPrice); // decremento i soldi del Player
                    UnlockPrice += UNLOCK_STEP;    // aumento il prezzo del prossimo blocco
                }
            }
            else
            {
                if (temp.GetType().Equals(BlockType.FIELD))
                {
                    FieldBlock myBlock = (FieldBlock)temp;
                    interaction.FieldInteraction(Pg, myBlock);
                }
            }
            if (Pg.NearestAnimal(Animals).IsPresent)
            {
                interaction.PlayerAnimal(Pg, Pg.NearestAnimal(Animals).Get());
            }
        }
Пример #3
0
 public GameImpl()
 {
     serialNum = new Random().Next();
     GenerateAnimals();
     Pg.GetInventory().AddSeeds(SeedType.WHEAT_SEED, 10);
     Pg.IncrementMoney(PRICE_START);
 }
Пример #4
0
 public void PgCreation()
 {
     currentPg = new PgCreator()
     {
         God = Gods.Ares
     }.Create();
 }
Пример #5
0
        public void Anular()
        {
            if (this.Existe && this.Anulado == false)
            {
                this.Estado = 90;

                // Marco el recibo como anulado
                qGen.Update Act = new qGen.Update(this.TablaDatos);
                Act.ColumnValues.AddWithValue("estado", this.Estado);
                Act.WhereClause = new qGen.Where(this.CampoId, this.Id);
                this.Connection.ExecuteNonQuery(Act);

                Lbl.Sys.Config.ActionLog(this.Connection, Lbl.Sys.Log.Acciones.Delete, this, null);

                if (this.DePago)
                {
                    foreach (Pago Pg in this.Pagos)
                    {
                        Pg.Anular();
                    }
                }
                else
                {
                    foreach (Cobro Cb in this.Cobros)
                    {
                        Cb.Anular();
                    }
                }

                DescancelarImpagos(this.Cliente, this.Facturas, this, this.DePago ? -this.Total : this.Total);
                this.Cliente.CuentaCorriente.Movimiento(true, this.Concepto, "Anulación de " + this.ToString(), this.DePago ? -this.Total : this.Total, this.Obs, null, this, null);
            }
        }
Пример #6
0
 public void Unregister(Pg pg)
 {
     if (controlledPg == pg)
     {
         controlledPg          = null;
         ControlledBackpack[0] = null;
     }
 }
Пример #7
0
        protected override AICharacter RandomBuild(Pg.Level level)
        {
            var lvl = ((int)level);

            Name = Name.ValueIfNotNullOrElse("Orc");
            // God - can be null
            Stats = Stats.ValueIfNotNullOrElse(new GodsWill_ASCIIRPG.Stats(
                                                    StatsBuilder.RandomStats(
                                                        new Dictionary<StatsType, int>()
                                                        {
                                                            { StatsType.Strength, 2},
                                                            { StatsType.Toughness, 2},
                                                            { StatsType.Mental, -2},
                                                            { StatsType.InnatePower, -2},
                                                        })));
            var toughMod = ((Stats)Stats)[StatsType.Toughness].ModifierOfStat();
            MaximumPf = CurrentPf.ValueIfNotNullOrElse(Orc.healthDice.Max
                                                       + Dice.Throws(Orc.healthDice, lvl) 
                                                       + lvl * toughMod);
            CurrentPf = MaximumPf.ValueIfNotNullOrElse((int)MaximumPf);
            Hunger = Hunger.ValueIfNotNullOrElse((Orc.hungerDice.Max
                                        + Dice.Throws(Orc.hungerDice, lvl))
                                        * toughMod);
            MyAI = MyAI.ValueIfNotNullOrElse(new SimpleAI());
            MySensingMethod = MySensingMethod.ValueIfNotNullOrElse(AI.SensingAlgorythms.AllAround);
            PerceptionDistance = PerceptionDistance.ValueIfNotNullOrElse(5);
            //WornArmor - Can be null
            //EmbracedShield - Can be null
            //HandledWeapon - Can be null
            Backpack = Backpack.ValueIfNotNullOrElse(new Backpack());
            Symbol = Symbol.ValueIfNotNullOrElse("o");
            Color = Color.ValueIfNotNullOrElse(System.Drawing.Color.DarkOliveGreen);
            Description = Description.ValueIfNotNullOrElse("A greenish, smelly human-like creature. Strong, but usually not very smart.");
            Position = Position.ValueIfNotNullOrElse(new Coord());
            AlliedTo = AlliedTo.ValueIfNotNullOrElse(Allied.Enemy);

            var orc = new Orc(  Name,
                                (int)CurrentPf,
                                (int)MaximumPf,
                                (int)Hunger,
                                MyAI,
                                MySensingMethod,
                                (int)PerceptionDistance,
                                (Stats)Stats,
                                WornArmor,
                                EmbracedShield,
                                HandledWeapon,
                                Backpack,
                                God,
                                Symbol,
                                (System.Drawing.Color)Color,
                                Description,
                                (Coord)Position,
                                (Allied)AlliedTo);

            return orc;
        }
Пример #8
0
        public static Item GenerateByBuilderType(  Type type, 
                                            Pg.Level level = Pg.Level.Novice, 
                                            Coord position = new Coord())
        {

            return Generators.ContainsKey(type)
                ? Generators[type].GenerateRandom(level, position)
                : null;
        }
Пример #9
0
        public void Loop()
        {
            Pg.move();
            //pg.checkCollision(map.GetMapSet(), x->x.isWalkable());

            foreach (Animal a in Animals)
            {
                a.RandomMove(Map.GetMapSet());
            }
        }
Пример #10
0
 public void SaysWhatPurchased(Pg controlledPg)
 {
     if (lastSoldPurchased != null)
     {
         controlledPg.NotifyListeners(String.Format("Sold {0}", lastSoldPurchased.Name));
     }
     else
     {
         controlledPg.NotifyListeners("UNEXPECTED");
     }
 }
Пример #11
0
        public void UnregisterAll()
        {
            if (controlledMerchant != null)
            {
                controlledMerchant.UnregisterListener(singleLogMerchant);
            }

            controlledPg       = null;
            controlledMerchant = null;

            for (int i = 0; i < controlledBackpack.Length; i++)
            {
                controlledBackpack[i] = null;
                descriptionList[i].Items.Clear();
            }
        }
Пример #12
0
        public override string ToString()
        {
            string Res = null;

            foreach (Pago Pg in this)
            {
                if (Res == null)
                {
                    Res = Pg.ToString();
                }
                else
                {
                    Res += System.Environment.NewLine + Pg.ToString();
                }
            }
            return(Res);
        }
Пример #13
0
        public bool Sell(Item item, Pg to)
        {
            lastSoldPurchased = null;

            if (item.IsSellable)
            {
                var cost = (int)Math.Round(GoldModifiersByInclination[Inclination].Sell * item.Cost);

                Gold gold;
                if (to.GiveAwayGold(cost, out gold))
                {
                    this.PickUpGold(gold);

                    var itemType = item.GetType();
                    if (!typeof(ItemStack).IsAssignableFrom(itemType) ||
                        item.SellableOnlyAsFullStack)
                    {
                        this.Backpack.Remove(item);
                        to.Backpack.Add(item);

                        lastSoldPurchased = item;
                    }
                    else
                    {
                        var firstItem = ((ItemStack)item)[0];
                        this.Backpack.Remove(firstItem);
                        to.Backpack.Add(firstItem);

                        lastSoldPurchased = firstItem;
                    }


                    merchantView.NotifyBuyerGold(to.MyGold);
                    NotifyExcange();

                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            return(false);
        }
Пример #14
0
            public void GameInitialization()
            {
                var map = CurrentMap;

                currentPg = map.CurrentPg;

                if (currentPg == null)
                {
                    PgCreation();
                    CurrentPg.InsertInMap(map, map.PlayerInitialPosition, overwrite: false);
                }
                else
                {
                    CurrentPg.InsertInMap(map, currentPg.Position, overwrite: true);
                }

                var aiCharacters = map.AICharacters.ToList();
                var merchants    = map.Merchants.ToList();
                var traps        = map.Traps.ToList();

                pgViewers.ForEach(pgViewer => CurrentPg.RegisterView(pgViewer));

                aiCharacters.ForEach(aiC => atomListeners.ForEach(listener => aiC.RegisterView(listener)));
                traps.ForEach(trap => atomListeners.ForEach(listener => trap.RegisterView(listener)));

                atomListeners.ForEach(listener => currentPg.RegisterView(listener));
                currentPg.RegisterView(singleMsgListener);

                merchantViewers.ForEach(mV => merchants.ForEach(m => m.RegisterView(mV)));
                merchants.ForEach(m => merchantController.Register(m));
                merchants.ForEach(m => atomListeners.ForEach(listener => m.RegisterSecondaryView(listener)));

                sheetViews.ForEach(sheet => currentPg.RegisterView(sheet));
                backpackViewers.ForEach(viewer => currentPg.Backpack.RegisterView(viewer));
                spellbookViewers.ForEach(viewer => currentPg.Spellbook.RegisterView(viewer));
                secondarySpellsViewers.ForEach(secondarySpellsViewer => currentPg.Spellbook.RegisterSecondaryView(secondarySpellsViewer));

                pgController.Register(CurrentPg);
                pgController.BackpackController.Register(CurrentPg.Backpack);
                pgController.SpellbookController.Register(CurrentPg.Spellbook);

                aiController.RegisterAll(aiCharacters);
                Animation.RegisterAnimationViewer(animationViewer);
            }
Пример #15
0
        public async Task <IActionResult> Book(Book b)
        {
            _log4net.Info("Booking Done");
            if (HttpContext.Session.GetString("token") == null)
            {
                return(RedirectToAction("Login", "Login"));
            }
            else
            {
                Pg p = new Pg();

                using (var client = new HttpClient())
                {
                    var contentType = new MediaTypeWithQualityHeaderValue("application/json");
                    client.DefaultRequestHeaders.Accept.Add(contentType);

                    client.DefaultRequestHeaders.Authorization =
                        new AuthenticationHeaderValue("Bearer", HttpContext.Session.GetString("token"));

                    using (var response = await client.GetAsync("https://localhost:44345/api/Pg/" + b.pg_Id))
                    {
                        string apiResponse = await response.Content.ReadAsStringAsync();

                        p = JsonConvert.DeserializeObject <Pg>(apiResponse);
                    }

                    b.TotalCost = b.No_ofMonth * p.Rent_per_month;
                    b.UserId    = Convert.ToInt32(HttpContext.Session.GetInt32("Userid"));



                    StringContent content = new StringContent(JsonConvert.SerializeObject(b), Encoding.UTF8, "application/json");

                    using (var response = await client.PostAsync("https://localhost:44372/api/Booking/", content))
                    {
                        string apiResponse = await response.Content.ReadAsStringAsync();

                        b = JsonConvert.DeserializeObject <Book>(apiResponse);
                    }
                }
                return(RedirectToAction("Index"));
            }
        }
Пример #16
0
        private void EvaluateInclination(Pg interactor)
        {
            var thr = this.ThresholdInclinationByLevel[interactor.CurrentLevel];

            var res = Dice.Throws(new Dice(100));

            if (res <= thr.UnfriendlyThr)
            {
                Inclination = MerchantInclination.Unfriendly;
            }
            else if (res <= thr.UnfriendlyThr)
            {
                Inclination = MerchantInclination.Friendly;
            }
            else
            {
                Inclination = MerchantInclination.Normal;
            }
        }
Пример #17
0
 public abstract Item GenerateRandom(Pg.Level level, Coord position);
Пример #18
0
 public void BringUpAndFocus(Pg interactor)
 {
     Register(interactor);
     Notify(ControllerCommand.Merchant_Open);
 }
Пример #19
0
            public void GameInitialization( PgController pgController, 
                                            AIController aiController,
                                            IMapViewer mapViewer,
                                            IAtomListener singleMsgListener,
                                            IAnimationViewer animationViewer,
                                            List<IAtomListener> atomListeners,
                                            List<ISheetViewer> sheetViews,
                                            List<IBackpackViewer> backpackViewers,
                                            List<ISpellbookViewer> spellbookViewers,
                                            List<IAtomListener> secondarySpellsViewers)
            {
                // Map generation
                var mapBuilder = new MapBuilder();

                mapBuilder.AddViewer(mapViewer);
                mapBuilder.AddSingleMessageListener(singleMsgListener);

#if DEBUG_MAP
                mapBuilder.Explored = TernaryValue.Unexplored;
                mapBuilder.Lightened = true;
#if RANDOM_MAP_GENERATION
                mapBuilder.Height = 40;
                mapBuilder.Width = 30;

                mapBuilder.MapCreationMode = MapBuilder.TableCreationMode.Random;
#else
#if !DEBUG_MAP_FROM_FILE
                mapBuilder.Height = 30;
                mapBuilder.Width = 19;

                //mapBuilder.AddAtom(new Wall(new Coord() { X = 10, Y = 10 }));
                //mapBuilder.AddAtom(new Wall(new Coord() { X = 11, Y = 10 }));
                //mapBuilder.AddAtom(new Wall(new Coord() { X = 12, Y = 10 }));

                // Orc Covering Walls
                for (int x = 9; x < 12; x++)
                {
                    mapBuilder.AddAtom(new Wall(new Coord(x, 10)));
                }
                for (int y = 10; y < 14; y++)
                {
                    mapBuilder.AddAtom(new Wall(new Coord(8, y)));
                }
                // 4 Corners
                mapBuilder.AddAtom(new Wall(new Coord() { X = 0, Y = 0 }));
                mapBuilder.AddAtom(new Wall(new Coord() { X = 0, Y = mapBuilder.Height - 1 }));
                mapBuilder.AddAtom(new Wall(new Coord() { X = mapBuilder.Width - 1, Y = 0 }));
                mapBuilder.AddAtom(new Wall(new Coord() { X = mapBuilder.Width - 1, Y = mapBuilder.Height - 1 }));

                mapBuilder.PlayerInitialPosition = new Coord() { X = 1, Y = 1 };

                mapBuilder.AddAtom(new Gold(10, new Coord(2, 2)));
                mapBuilder.AddAtom(new LongSword(position: new Coord() { X = 7, Y = 4 }));
                mapBuilder.AddAtom(new Leather(position: new Coord() { X = 7, Y = 3 }));
                for (int i = 8; i < 18; i++)
                {
                    for (int j = 4; j < 14; j++)
                    {
                        if (i % 2 == 0)
                        {
                            mapBuilder.AddAtom(new LongSword(position: new Coord() { X = i, Y = j }));
                        }
                        else
                        {
                            mapBuilder.AddAtom(new FlamingLongSword(position: new Coord() { X = i, Y = j }));
                        }
                    }
                }

                var book1 = ItemGenerators.GenerateByBuilderType(typeof(PrayerBookBuilder), position: new Coord(2, 1));
                mapBuilder.AddAtom(book1);

                mapBuilder.AddAtom(new WoodenShield(position: Coord.Random(mapBuilder.Width, mapBuilder.Height)));
                var orcBuilder1 = AICharacter.DummyCharacter(typeof(Orc)).Builder;
                orcBuilder1.Position = new Coord(10, 12);
                var orc1 = orcBuilder1.Build();
                mapBuilder.AddAtom(orc1);


                var orcBuilder2 = AICharacter.DummyCharacter(typeof(Orc)).Builder;
                orcBuilder2.Position = new Coord(13, 12);
                var orc2 = orcBuilder2.Build();
                mapBuilder.AddAtom(orc2);

                currentPg = new PgCreator() { God = Gods.Ares }.Create();
                
                currentPg.Listeners.ForEach(listener => orc1.RegisterListener(listener));
                currentPg.Listeners.ForEach(listener => orc2.RegisterListener(listener));
                //aiController.Register(orc1);
                //aiController.Register(orc2);
#endif
#endif
#else
                mapBuilder.LoadFromFile("");
#endif
#if DEBUG_MAP_FROM_FILE
                mapBuilder.MapCreationMode = MapBuilder.TableCreationMode.FromFile;
#endif
                var map = mapBuilder.Create();
#if !DEBUG_MAP_FROM_FILE
                if (currentPg == null)
                {
                    currentPg = new PgCreator() { God = Gods.Ares }.Create();
                }
                CurrentPg.InsertInMap(map, map.PlayerInitialPosition, overwrite: false);
#else
                currentPg = map.CurrentPg;

                if (currentPg == null)
                {
                    currentPg = new PgCreator() { God = Gods.Ares }.Create();
                    CurrentPg.InsertInMap(map, map.PlayerInitialPosition, overwrite: false);
                }
                else
                {
                    CurrentPg.InsertInMap(map, currentPg.Position, overwrite: true);
                }
#endif
                var aiCharacters = map.AICharacters.ToList();

                atomListeners.ForEach(listener => currentPg.RegisterListener(listener));
                aiCharacters.ForEach(aiC => currentPg.Listeners.ForEach(listener => aiC.RegisterListener(listener)));
                sheetViews.ForEach(sheet => currentPg.RegisterSheet(sheet));
                backpackViewers.ForEach(viewer => currentPg.Backpack.RegisterViewer(viewer));
                spellbookViewers.ForEach(viewer => currentPg.Spellbook.RegisterViewer(viewer));
                secondarySpellsViewers.ForEach(secondarySpellsViewer => currentPg.Spellbook.RegisterSecondaryView(secondarySpellsViewer));

                pgController.Register(CurrentPg);
                pgController.BackpackController.Register(CurrentPg.Backpack);
                pgController.SpellbookController.Register(CurrentPg.Spellbook);

                aiController.RegisterAll(aiCharacters);
                Animation.RegisterAnimationViewer(animationViewer);
            }
Пример #20
0
            public void DebugMap()
            {
                MapBuilder.Explored = TernaryValue.Unexplored;
                MapBuilder.Lightened = true;

                MapBuilder.Height = 30;
                MapBuilder.Width = 19;

                //mapBuilder.AddAtom(new Wall(new Coord() { X = 10, Y = 10 }));
                //mapBuilder.AddAtom(new Wall(new Coord() { X = 11, Y = 10 }));
                //mapBuilder.AddAtom(new Wall(new Coord() { X = 12, Y = 10 }));

                // Orc Covering Walls
                for (int x = 9; x < 12; x++)
                {
                    MapBuilder.AddAtom(new Wall(new Coord(x, 10)));
                }
                for (int y = 10; y < 14; y++)
                {
                    MapBuilder.AddAtom(new Wall(new Coord(8, y)));
                }
                // 4 Corners
                MapBuilder.AddAtom(new Wall(new Coord() { X = 0, Y = 0 }));
                MapBuilder.AddAtom(new Wall(new Coord() { X = 0, Y = MapBuilder.Height - 1 }));
                MapBuilder.AddAtom(new Wall(new Coord() { X = MapBuilder.Width - 1, Y = 0 }));
                MapBuilder.AddAtom(new Wall(new Coord() { X = MapBuilder.Width - 1, Y = MapBuilder.Height - 1 }));

                MapBuilder.PlayerInitialPosition = new Coord() { X = 1, Y = 1 };

                MapBuilder.AddAtom(new Gold(10, new Coord(2, 2)));
                MapBuilder.AddAtom(new LongSword(position: new Coord() { X = 7, Y = 4 }));
                MapBuilder.AddAtom(new Leather(position: new Coord() { X = 7, Y = 3 }));
                for (int i = 8; i < 18; i++)
                {
                    for (int j = 4; j < 14; j++)
                    {
                        if (i % 2 == 0)
                        {
                            MapBuilder.AddAtom(new LongSword(position: new Coord() { X = i, Y = j }));
                        }
                        else
                        {
                            MapBuilder.AddAtom(new FlamingLongSword(position: new Coord() { X = i, Y = j }));
                        }
                    }
                }

                var book1 = ItemGenerators.GenerateByBuilderType(typeof(PrayerBookBuilder), position: new Coord(2, 1));
                MapBuilder.AddAtom(book1);

                for (int x = 6; x < 15; x++)
                {
                    for (int y = 6; y < 15; y++)
                    {
                        var stackableItem = new StackItemTest(color: System.Drawing.Color.Blue,
                                                                position: new Coord(x, y),
                                                                uses: Item._UnlimitedUses);
                        MapBuilder.AddAtom(stackableItem);
                    }
                }

                MapBuilder.AddAtom(new WoodenShield(position: Coord.Random(MapBuilder.Width, MapBuilder.Height)));
                var orcBuilder1 = AICharacter.DummyCharacter(typeof(Orc)).Builder;
                orcBuilder1.Position = new Coord(10, 12);
                var orc1 = orcBuilder1.Build();
                MapBuilder.AddAtom(orc1);


                var orcBuilder2 = AICharacter.DummyCharacter(typeof(Orc)).Builder;
                orcBuilder2.Position = new Coord(13, 12);
                var orc2 = orcBuilder2.Build();
                MapBuilder.AddAtom(orc2);

                var book2 = new PrayerBookBuilder().GenerateRandom(Pg.Level.Novice, new Coord());

                var merchantBuilder = new MerchantBuilder();
                merchantBuilder.AddItem(new LongSword());
                merchantBuilder.AddItem(book2);
                for (int i = 0; i < 20; i++)
                {
                    merchantBuilder.AddItem(new Meat());
                }
                merchantBuilder.Position = new Coord(4, 4);

                MapBuilder.AddAtom(merchantBuilder.Build());

                var aTrap = new ArrowTrap(new Coord(7, 7));
                MapBuilder.AddAtom(aTrap);

                currentPg = new PgCreator() { God = Gods.Ares }.Create();

                //currentPg.Listeners.ForEach(listener => orc1.RegisterListener(listener));
                //currentPg.Listeners.ForEach(listener => orc2.RegisterListener(listener));
            }
Пример #21
0
 public virtual AICharacter Build(Pg.Level level = Pg.Level.Novice)
 {
     var aiChar = RandomBuild(level);
     return aiChar;
 }
Пример #22
0
 public Prerequisite(Pg.Level minimumLevel)
 {
     MinimumLevel = minimumLevel;
 }
Пример #23
0
 public void Show(Map map, Pg pg, int perceptionRange)
 {
     this.InsertInMap(map, pg.Position);
     controller             = pg;
     squaredPerceptionRange = perceptionRange * perceptionRange;
 }
Пример #24
0
            public void DebugMap()
            {
                MapBuilder.Explored  = TernaryValue.Unexplored;
                MapBuilder.Lightened = true;

                MapBuilder.Height = 30;
                MapBuilder.Width  = 19;

                //mapBuilder.AddAtom(new Wall(new Coord() { X = 10, Y = 10 }));
                //mapBuilder.AddAtom(new Wall(new Coord() { X = 11, Y = 10 }));
                //mapBuilder.AddAtom(new Wall(new Coord() { X = 12, Y = 10 }));

                // Orc Covering Walls
                for (int x = 9; x < 12; x++)
                {
                    MapBuilder.AddAtom(new Wall(new Coord(x, 10)));
                }
                for (int y = 10; y < 14; y++)
                {
                    MapBuilder.AddAtom(new Wall(new Coord(8, y)));
                }
                // 4 Corners
                MapBuilder.AddAtom(new Wall(new Coord()
                {
                    X = 0, Y = 0
                }));
                MapBuilder.AddAtom(new Wall(new Coord()
                {
                    X = 0, Y = MapBuilder.Height - 1
                }));
                MapBuilder.AddAtom(new Wall(new Coord()
                {
                    X = MapBuilder.Width - 1, Y = 0
                }));
                MapBuilder.AddAtom(new Wall(new Coord()
                {
                    X = MapBuilder.Width - 1, Y = MapBuilder.Height - 1
                }));

                MapBuilder.PlayerInitialPosition = new Coord()
                {
                    X = 1, Y = 1
                };

                MapBuilder.AddAtom(new Gold(10, new Coord(2, 2)));
                MapBuilder.AddAtom(new LongSword(position: new Coord()
                {
                    X = 7, Y = 4
                }));
                MapBuilder.AddAtom(new Leather(position: new Coord()
                {
                    X = 7, Y = 3
                }));
                for (int i = 8; i < 18; i++)
                {
                    for (int j = 4; j < 14; j++)
                    {
                        if (i % 2 == 0)
                        {
                            MapBuilder.AddAtom(new LongSword(position: new Coord()
                            {
                                X = i, Y = j
                            }));
                        }
                        else
                        {
                            MapBuilder.AddAtom(new FlamingLongSword(position: new Coord()
                            {
                                X = i, Y = j
                            }));
                        }
                    }
                }

                var book1 = ItemGenerators.GenerateByBuilderType(typeof(PrayerBookBuilder), position: new Coord(2, 1));

                MapBuilder.AddAtom(book1);

                for (int x = 6; x < 15; x++)
                {
                    for (int y = 6; y < 15; y++)
                    {
                        var stackableItem = new StackItemTest(color: System.Drawing.Color.Blue,
                                                              position: new Coord(x, y),
                                                              uses: Item._UnlimitedUses);
                        MapBuilder.AddAtom(stackableItem);
                    }
                }

                MapBuilder.AddAtom(new WoodenShield(position: Coord.Random(MapBuilder.Width, MapBuilder.Height)));
                var orcBuilder1 = AICharacter.DummyCharacter(typeof(Orc)).Builder;

                orcBuilder1.Position = new Coord(10, 12);
                var orc1 = orcBuilder1.Build();

                MapBuilder.AddAtom(orc1);


                var orcBuilder2 = AICharacter.DummyCharacter(typeof(Orc)).Builder;

                orcBuilder2.Position = new Coord(13, 12);
                var orc2 = orcBuilder2.Build();

                MapBuilder.AddAtom(orc2);

                var book2 = new PrayerBookBuilder().GenerateRandom(Pg.Level.Novice, new Coord());

                var merchantBuilder = new MerchantBuilder();

                merchantBuilder.AddItem(new LongSword());
                merchantBuilder.AddItem(book2);
                for (int i = 0; i < 20; i++)
                {
                    merchantBuilder.AddItem(new Meat());
                }
                merchantBuilder.Position = new Coord(4, 4);

                MapBuilder.AddAtom(merchantBuilder.Build());

                var aTrap = new ArrowTrap(new Coord(7, 7));

                MapBuilder.AddAtom(aTrap);

                currentPg = new PgCreator()
                {
                    God = Gods.Ares
                }.Create();

                //currentPg.Listeners.ForEach(listener => orc1.RegisterListener(listener));
                //currentPg.Listeners.ForEach(listener => orc2.RegisterListener(listener));
            }
Пример #25
0
            public void GameInitialization(PgController pgController,
                                           AIController aiController,
                                           IMapViewer mapViewer,
                                           IAtomListener singleMsgListener,
                                           IAnimationViewer animationViewer,
                                           List <IAtomListener> atomListeners,
                                           List <ISheetViewer> sheetViews,
                                           List <IBackpackViewer> backpackViewers,
                                           List <ISpellbookViewer> spellbookViewers,
                                           List <IAtomListener> secondarySpellsViewers)
            {
                // Map generation
                var mapBuilder = new MapBuilder();

                mapBuilder.AddViewer(mapViewer);
                mapBuilder.AddSingleMessageListener(singleMsgListener);

#if DEBUG_MAP
                mapBuilder.Explored  = TernaryValue.Unexplored;
                mapBuilder.Lightened = true;
#if RANDOM_MAP_GENERATION
                mapBuilder.Height = 40;
                mapBuilder.Width  = 30;

                mapBuilder.MapCreationMode = MapBuilder.TableCreationMode.Random;
#else
#if !DEBUG_MAP_FROM_FILE
                mapBuilder.Height = 30;
                mapBuilder.Width  = 19;

                //mapBuilder.AddAtom(new Wall(new Coord() { X = 10, Y = 10 }));
                //mapBuilder.AddAtom(new Wall(new Coord() { X = 11, Y = 10 }));
                //mapBuilder.AddAtom(new Wall(new Coord() { X = 12, Y = 10 }));

                // Orc Covering Walls
                for (int x = 9; x < 12; x++)
                {
                    mapBuilder.AddAtom(new Wall(new Coord(x, 10)));
                }
                for (int y = 10; y < 14; y++)
                {
                    mapBuilder.AddAtom(new Wall(new Coord(8, y)));
                }
                // 4 Corners
                mapBuilder.AddAtom(new Wall(new Coord()
                {
                    X = 0, Y = 0
                }));
                mapBuilder.AddAtom(new Wall(new Coord()
                {
                    X = 0, Y = mapBuilder.Height - 1
                }));
                mapBuilder.AddAtom(new Wall(new Coord()
                {
                    X = mapBuilder.Width - 1, Y = 0
                }));
                mapBuilder.AddAtom(new Wall(new Coord()
                {
                    X = mapBuilder.Width - 1, Y = mapBuilder.Height - 1
                }));

                mapBuilder.PlayerInitialPosition = new Coord()
                {
                    X = 1, Y = 1
                };

                mapBuilder.AddAtom(new Gold(10, new Coord(2, 2)));
                mapBuilder.AddAtom(new LongSword(position: new Coord()
                {
                    X = 7, Y = 4
                }));
                mapBuilder.AddAtom(new Leather(position: new Coord()
                {
                    X = 7, Y = 3
                }));
                for (int i = 8; i < 18; i++)
                {
                    for (int j = 4; j < 14; j++)
                    {
                        if (i % 2 == 0)
                        {
                            mapBuilder.AddAtom(new LongSword(position: new Coord()
                            {
                                X = i, Y = j
                            }));
                        }
                        else
                        {
                            mapBuilder.AddAtom(new FlamingLongSword(position: new Coord()
                            {
                                X = i, Y = j
                            }));
                        }
                    }
                }

                var book1 = ItemGenerators.GenerateByBuilderType(typeof(PrayerBookBuilder), position: new Coord(2, 1));
                mapBuilder.AddAtom(book1);

                mapBuilder.AddAtom(new WoodenShield(position: Coord.Random(mapBuilder.Width, mapBuilder.Height)));
                var orcBuilder1 = AICharacter.DummyCharacter(typeof(Orc)).Builder;
                orcBuilder1.Position = new Coord(10, 12);
                var orc1 = orcBuilder1.Build();
                mapBuilder.AddAtom(orc1);


                var orcBuilder2 = AICharacter.DummyCharacter(typeof(Orc)).Builder;
                orcBuilder2.Position = new Coord(13, 12);
                var orc2 = orcBuilder2.Build();
                mapBuilder.AddAtom(orc2);

                currentPg = new PgCreator()
                {
                    God = Gods.Ares
                }.Create();

                currentPg.Listeners.ForEach(listener => orc1.RegisterListener(listener));
                currentPg.Listeners.ForEach(listener => orc2.RegisterListener(listener));
                //aiController.Register(orc1);
                //aiController.Register(orc2);
#endif
#endif
#else
                mapBuilder.LoadFromFile("");
#endif
#if DEBUG_MAP_FROM_FILE
                mapBuilder.MapCreationMode = MapBuilder.TableCreationMode.FromFile;
#endif
                var map = mapBuilder.Create();
#if !DEBUG_MAP_FROM_FILE
                if (currentPg == null)
                {
                    currentPg = new PgCreator()
                    {
                        God = Gods.Ares
                    }.Create();
                }
                CurrentPg.InsertInMap(map, map.PlayerInitialPosition, overwrite: false);
#else
                currentPg = map.CurrentPg;

                if (currentPg == null)
                {
                    currentPg = new PgCreator()
                    {
                        God = Gods.Ares
                    }.Create();
                    CurrentPg.InsertInMap(map, map.PlayerInitialPosition, overwrite: false);
                }
                else
                {
                    CurrentPg.InsertInMap(map, currentPg.Position, overwrite: true);
                }
#endif
                var aiCharacters = map.AICharacters.ToList();

                atomListeners.ForEach(listener => currentPg.RegisterListener(listener));
                aiCharacters.ForEach(aiC => currentPg.Listeners.ForEach(listener => aiC.RegisterListener(listener)));
                sheetViews.ForEach(sheet => currentPg.RegisterSheet(sheet));
                backpackViewers.ForEach(viewer => currentPg.Backpack.RegisterViewer(viewer));
                spellbookViewers.ForEach(viewer => currentPg.Spellbook.RegisterViewer(viewer));
                secondarySpellsViewers.ForEach(secondarySpellsViewer => currentPg.Spellbook.RegisterSecondaryView(secondarySpellsViewer));

                pgController.Register(CurrentPg);
                pgController.BackpackController.Register(CurrentPg.Backpack);
                pgController.SpellbookController.Register(CurrentPg.Spellbook);

                aiController.RegisterAll(aiCharacters);
                Animation.RegisterAnimationViewer(animationViewer);
            }
Пример #26
0
        public static Item GenerateRandom(Pg.Level level)
        {
            Item item = null;

            var type = typeof(Item);
            var itemClasses = AppDomain.CurrentDomain.GetAssemblies()
                                        .SelectMany(s => s.GetTypes())
                                        .Where(p => type.IsAssignableFrom(p)).ToArray();

            var ix = 0; // TODO: Random index generation --> i.e. The type of item

            var luck = Dice.Throws(new Dice(20));
            var actualLevel = level;
            
            if(luck < 3)
            {
                actualLevel = actualLevel.Previous();
            }
            if(luck > 18)
            {
                actualLevel = actualLevel.Next();
            }

            var method = itemClasses[ix].GetMethods().Where(m => m.GetCustomAttributes(typeof(Generator), false).Length > 0).FirstOrDefault();

            if (method == null)
            {
                throw new Exception("Unexpected null method");
            }

            return (Item)method.Invoke(null, new object[] { actualLevel });
        }
Пример #27
0
 public void BeginTransaction(Pg interactor)
 {
     merchantView.NotifyMerchantName(this.Name);
     merchantView.BringUpAndFocus(interactor);
 }
Пример #28
0
        public OnVeryGoodPrayResult(Pg.Level forLevel)
            : base(forLevel)
        {

        }
Пример #29
0
 public void Start(bool fromScratch = false)
 {
     Pg.Start(fromScratch);
 }
Пример #30
0
        public override string ObtenerValorCampo(string nombreCampo, string formato)
        {
            switch (nombreCampo.ToUpperInvariant())
            {
            case "CLIENTE":
            case "CLIENTE.NOMBRE":
                return(this.Comprobante.Cliente.ToString());

            case "LOCALIDAD":
            case "LOCALIDAD.NOMBRE":
            case "CLIENTE.LOCALIDAD":
            case "CLIENTE.LOCALIDAD.NOMBRE":
                if (this.Comprobante.Cliente.Localidad == null)
                {
                    return("");
                }
                else
                {
                    return(this.Comprobante.Cliente.Localidad.ToString());
                }

            case "DOMICILIO":
            case "CLIENTE.DOMICILIO":
                if (this.Comprobante.Cliente.Domicilio != null && this.Comprobante.Cliente.Domicilio.Length > 0)
                {
                    return(this.Comprobante.Cliente.Domicilio);
                }
                else
                {
                    return(this.Comprobante.Cliente.DomicilioLaboral);
                }

            case "CLIENTE.DOCUMENTO":
                if (this.Comprobante.Cliente.ClaveTributaria != null)
                {
                    return(this.Comprobante.Cliente.ClaveTributaria.ToString());
                }
                else
                {
                    return(this.Comprobante.Cliente.NumeroDocumento);
                }

            case "CUIT":
            case "CLIENTE.CUIT":
                if (this.Comprobante.Cliente.ClaveTributaria != null)
                {
                    return(this.Comprobante.Cliente.ClaveTributaria.ToString());
                }
                else
                {
                    return("");
                }

            case "IVA":
            case "CLIENTE.IVA":
                return(this.Comprobante.Cliente.SituacionTributaria.ToString());

            case "CLIENTE.ID":
                return(this.Comprobante.Cliente.Id.ToString());

            case "VENDEDOR":
            case "VENDEDOR.NOMBRE":
                return(this.Comprobante.Vendedor.ToString());

            case "TOTAL":
            case "COMPROBANTE.TOTAL":
                return(Lfx.Types.Formatting.FormatCurrencyForPrint(this.Recibo.Total, Lfx.Workspace.Master.CurrentConfig.Moneda.DecimalesFinal));

            case "SONPESOS":
                return(Lfx.Types.Formatting.SpellNumber(this.Recibo.Total));

            case "FACTURAS":
                if (Recibo.Facturas.Count > 0)
                {
                    string Res = null;
                    foreach (Lbl.Comprobantes.ComprobanteImporte CompImp in Recibo.Facturas)
                    {
                        Lbl.Comprobantes.ComprobanteConArticulos Comprob = CompImp.Comprobante;
                        if (Res == null)
                        {
                            Res = Comprob.ToString();
                        }
                        else
                        {
                            Res += ", " + Comprob.ToString();
                        }
                    }
                    return(Res);
                }
                else
                {
                    return("");
                }

            case "VALORES":
                System.Text.StringBuilder Valores = new System.Text.StringBuilder();
                if (Recibo.Pagos != null && Recibo.Pagos.Count > 0)
                {
                    foreach (Lbl.Comprobantes.Pago Pg in Recibo.Pagos)
                    {
                        switch (Pg.FormaDePago.Tipo)
                        {
                        case Lbl.Pagos.TiposFormasDePago.Efectivo:
                            Valores.AppendLine("Efectivo                 : " + Lbl.Sys.Config.Moneda.Simbolo + " " + Lfx.Types.Formatting.FormatCurrency(Pg.Importe, Lfx.Workspace.Master.CurrentConfig.Moneda.Decimales));
                            break;

                        case Lbl.Pagos.TiposFormasDePago.ChequeTerceros:
                        case Lbl.Pagos.TiposFormasDePago.ChequePropio:
                            Valores.AppendLine("Cheque                   : " + Lbl.Sys.Config.Moneda.Simbolo + " " + Lfx.Types.Formatting.FormatCurrency(Pg.Importe, Lfx.Workspace.Master.CurrentConfig.Moneda.Decimales));
                            Valores.AppendLine("                           Nº " + Pg.Cheque.Numero + " del banco " + Pg.Cheque.Banco.ToString());
                            Valores.AppendLine("                           emitido por " + Pg.Cheque.Emisor);
                            Valores.AppendLine("                           el día " + Lfx.Types.Formatting.FormatDate(Pg.Cheque.FechaEmision));
                            Valores.AppendLine("                           pagadero el " + Lfx.Types.Formatting.FormatDate(Pg.Cheque.FechaCobro));
                            break;

                        case Lbl.Pagos.TiposFormasDePago.Tarjeta:
                            Valores.AppendLine("Pago con Tarjeta         : " + Lbl.Sys.Config.Moneda.Simbolo + " " + Lfx.Types.Formatting.FormatCurrency(Pg.Importe, Lfx.Workspace.Master.CurrentConfig.Moneda.Decimales));
                            Valores.AppendLine("                           tarjeta " + Pg.ConceptoTexto.ToString());
                            break;

                        case Lbl.Pagos.TiposFormasDePago.Caja:
                            Valores.AppendLine("Ingreso en Cuenta        : " + Lbl.Sys.Config.Moneda.Simbolo + " " + Lfx.Types.Formatting.FormatCurrency(Pg.Importe, Lfx.Workspace.Master.CurrentConfig.Moneda.Decimales));
                            Valores.AppendLine("                           cuenta " + Pg.CajaOrigen.ToString());
                            break;

                        default:
                            Valores.AppendLine("Otro Pago                : " + Lbl.Sys.Config.Moneda.Simbolo + " " + Lfx.Types.Formatting.FormatCurrency(Pg.Importe, Lfx.Workspace.Master.CurrentConfig.Moneda.Decimales));
                            Valores.AppendLine("                           " + Pg.ToString());
                            break;
                        }
                    }
                }
                else if (Recibo.Cobros != null && Recibo.Cobros.Count > 0)
                {
                    foreach (Lbl.Comprobantes.Cobro Pg in Recibo.Cobros)
                    {
                        switch (Pg.FormaDePago.Tipo)
                        {
                        case Lbl.Pagos.TiposFormasDePago.Efectivo:
                            Valores.AppendLine("Efectivo                 : " + Lbl.Sys.Config.Moneda.Simbolo + " " + Lfx.Types.Formatting.FormatCurrency(Pg.Importe, Lfx.Workspace.Master.CurrentConfig.Moneda.Decimales));
                            break;

                        case Lbl.Pagos.TiposFormasDePago.ChequeTerceros:
                        case Lbl.Pagos.TiposFormasDePago.ChequePropio:
                            Valores.AppendLine("Cheque                   : " + Lbl.Sys.Config.Moneda.Simbolo + " " + Lfx.Types.Formatting.FormatCurrency(Pg.Importe, Lfx.Workspace.Master.CurrentConfig.Moneda.Decimales));
                            Valores.AppendLine("                           Nº " + Pg.Cheque.Numero + " del banco " + Pg.Cheque.Banco.ToString());
                            Valores.AppendLine("                           emitido por " + Pg.Cheque.Emisor);
                            Valores.AppendLine("                           el día " + Lfx.Types.Formatting.FormatDate(Pg.Cheque.FechaEmision));
                            Valores.AppendLine("                           pagadero el " + Lfx.Types.Formatting.FormatDate(Pg.Cheque.FechaCobro));
                            break;

                        case Lbl.Pagos.TiposFormasDePago.Tarjeta:
                            Valores.AppendLine("Pago con Tarjeta         : " + Lbl.Sys.Config.Moneda.Simbolo + " " + Lfx.Types.Formatting.FormatCurrency(Pg.Importe, Lfx.Workspace.Master.CurrentConfig.Moneda.Decimales));
                            Valores.AppendLine("                           cupón " + Pg.Cupon.ToString());
                            break;

                        case Lbl.Pagos.TiposFormasDePago.Caja:
                            Valores.AppendLine("Ingreso en Cuenta        : " + Lbl.Sys.Config.Moneda.Simbolo + " " + Lfx.Types.Formatting.FormatCurrency(Pg.Importe, Lfx.Workspace.Master.CurrentConfig.Moneda.Decimales));
                            Valores.AppendLine("                           cuenta " + Pg.CajaDestino.ToString());
                            break;

                        default:
                            Valores.AppendLine("Otro Pago                : " + Lbl.Sys.Config.Moneda.Simbolo + " " + Lfx.Types.Formatting.FormatCurrency(Pg.Importe, Lfx.Workspace.Master.CurrentConfig.Moneda.Decimales));
                            Valores.AppendLine("                           " + Pg.ToString());
                            break;
                        }
                    }
                }

                //Agrego las facturas que corresponde al recibo.
                if (Recibo.Facturas != null)
                {
                    Valores.AppendLine("*********    COMPROBANTES    *********");
                    foreach (Lbl.Comprobantes.ComprobanteImporte fac in Recibo.Facturas)
                    {
                        Valores.AppendLine(fac.Comprobante.ToString());
                    }
                }
                return(Valores.ToString());

            default:
                return(base.ObtenerValorCampo(nombreCampo, formato));
            }
        }
Пример #31
0
 public void Show(Map map, Pg pg, int perceptionRange)
 {
     this.InsertInMap(map, pg.Position);
     controller = pg;
     squaredPerceptionRange = perceptionRange * perceptionRange;
 }
Пример #32
0
 protected abstract AICharacter RandomBuild(Pg.Level level);
Пример #33
0
        public void UnregisterAll()
        {
            if(controlledMerchant != null)
            {
                controlledMerchant.UnregisterListener(singleLogMerchant);
            }

            controlledPg = null;
            controlledMerchant = null;

            for (int i = 0; i < controlledBackpack.Length; i++)
            {
                controlledBackpack[i] = null;
                descriptionList[i].Items.Clear();
            }
        }
Пример #34
0
 public void PgCreation()
 {
     currentPg = new PgCreator() { God = Gods.Ares }.Create();
 }
Пример #35
0
 public void Unregister(Pg pg)
 {
     if (controlledPg == pg)
     {
         controlledPg = null;
         ControlledBackpack[0] = null;
     }
 }
Пример #36
0
            public void GameInitialization()
            {
                var map = CurrentMap;
                
                currentPg = map.CurrentPg;

                if (currentPg == null)
                {
                    PgCreation();
                    CurrentPg.InsertInMap(map, map.PlayerInitialPosition, overwrite: false);
                }
                else
                {
                    CurrentPg.InsertInMap(map, currentPg.Position, overwrite: true);
                }

                var aiCharacters = map.AICharacters.ToList();
                var merchants = map.Merchants.ToList();
                var traps = map.Traps.ToList();

                pgViewers.ForEach(pgViewer => CurrentPg.RegisterView(pgViewer));

                aiCharacters.ForEach(aiC => atomListeners.ForEach(listener => aiC.RegisterView(listener)));
                traps.ForEach(trap => atomListeners.ForEach(listener => trap.RegisterView(listener)));

                atomListeners.ForEach(listener => currentPg.RegisterView(listener));
                currentPg.RegisterView(singleMsgListener);

                merchantViewers.ForEach(mV => merchants.ForEach(m => m.RegisterView(mV)));
                merchants.ForEach(m => merchantController.Register(m));
                merchants.ForEach(m => atomListeners.ForEach(listener => m.RegisterSecondaryView(listener)));

                sheetViews.ForEach(sheet => currentPg.RegisterView(sheet));
                backpackViewers.ForEach(viewer => currentPg.Backpack.RegisterView(viewer));
                spellbookViewers.ForEach(viewer => currentPg.Spellbook.RegisterView(viewer));
                secondarySpellsViewers.ForEach(secondarySpellsViewer => currentPg.Spellbook.RegisterSecondaryView(secondarySpellsViewer));

                pgController.Register(CurrentPg);
                pgController.BackpackController.Register(CurrentPg.Backpack);
                pgController.SpellbookController.Register(CurrentPg.Spellbook);

                aiController.RegisterAll(aiCharacters);
                Animation.RegisterAnimationViewer(animationViewer);
            }
Пример #37
0
 public void Register(Pg pg)
 {
     controlledPg          = pg;
     ControlledBackpack[0] = pg.Backpack;
     NotifyBuyerGold(pg.MyGold);
 }
Пример #38
0
        private void MostrarValores()
        {
            ListaValores.BeginUpdate();
            ListaValores.Items.Clear();
            Lbl.Comprobantes.Recibo Rec = this.Elemento as Lbl.Comprobantes.Recibo;

            if (this.DePago)
            {
                foreach (Lbl.Comprobantes.Pago Pg in Rec.Pagos)
                {
                    ListViewItem itm = ListaValores.Items.Add(Pg.GetHashCode().ToString());
                    switch (Pg.FormaDePago.Tipo)
                    {
                    case Lbl.Pagos.TiposFormasDePago.Efectivo:
                        itm.SubItems.Add(new ListViewItem.ListViewSubItem(itm, Pg.FormaDePago.ToString()));
                        itm.SubItems.Add(new ListViewItem.ListViewSubItem(itm, Lfx.Types.Formatting.FormatCurrency(Pg.Importe, Lfx.Workspace.Master.CurrentConfig.Moneda.Decimales)));
                        break;

                    case Lbl.Pagos.TiposFormasDePago.Caja:
                        itm.SubItems.Add(new ListViewItem.ListViewSubItem(itm, Pg.FormaDePago.ToString()));
                        itm.SubItems.Add(new ListViewItem.ListViewSubItem(itm, Lfx.Types.Formatting.FormatCurrency(Pg.Importe, Lfx.Workspace.Master.CurrentConfig.Moneda.Decimales)));
                        itm.SubItems.Add(new ListViewItem.ListViewSubItem(itm, "Débito desde " + Pg.CajaOrigen.ToString()));
                        break;

                    default:
                        itm.SubItems.Add(Pg.FormaDePago.ToString());
                        itm.SubItems.Add(Lfx.Types.Formatting.FormatCurrency(Pg.Importe, Lfx.Workspace.Master.CurrentConfig.Moneda.Decimales));
                        itm.SubItems.Add(Pg.ToString());
                        break;
                    }
                }
                EtiquetaValoresImporte.Text = Lfx.Types.Formatting.FormatCurrency(Rec.Pagos.ImporteTotal, Lfx.Workspace.Master.CurrentConfig.Moneda.Decimales);
            }
            else
            {
                foreach (Lbl.Comprobantes.Cobro Cb in Rec.Cobros)
                {
                    ListViewItem itm = ListaValores.Items.Add(Cb.GetHashCode().ToString());
                    switch (Cb.FormaDePago.Tipo)
                    {
                    case Lbl.Pagos.TiposFormasDePago.Efectivo:
                        itm.SubItems.Add(new ListViewItem.ListViewSubItem(itm, Cb.FormaDePago.ToString()));
                        itm.SubItems.Add(new ListViewItem.ListViewSubItem(itm, Lfx.Types.Formatting.FormatCurrency(Cb.Importe, Lfx.Workspace.Master.CurrentConfig.Moneda.Decimales)));
                        break;

                    case Lbl.Pagos.TiposFormasDePago.Tarjeta:
                        itm.SubItems.Add(new ListViewItem.ListViewSubItem(itm, Cb.FormaDePago.ToString()));
                        itm.SubItems.Add(new ListViewItem.ListViewSubItem(itm, Lfx.Types.Formatting.FormatCurrency(Cb.Importe, Lfx.Workspace.Master.CurrentConfig.Moneda.Decimales)));
                        itm.SubItems.Add(new ListViewItem.ListViewSubItem(itm, "Cupón Nº " + Cb.Cupon.Numero + " de " + Cb.Cupon.FormaDePago.ToString()));
                        break;

                    case Lbl.Pagos.TiposFormasDePago.Caja:
                        itm.SubItems.Add(new ListViewItem.ListViewSubItem(itm, Cb.FormaDePago.ToString()));
                        itm.SubItems.Add(new ListViewItem.ListViewSubItem(itm, Lfx.Types.Formatting.FormatCurrency(Cb.Importe, Lfx.Workspace.Master.CurrentConfig.Moneda.Decimales)));
                        itm.SubItems.Add(new ListViewItem.ListViewSubItem(itm, "Depósito en " + Cb.CajaDestino.ToString()));
                        break;

                    default:
                        itm.SubItems.Add(Cb.FormaDePago.ToString());
                        itm.SubItems.Add(Lfx.Types.Formatting.FormatCurrency(Cb.Importe, Lfx.Workspace.Master.CurrentConfig.Moneda.Decimales));
                        itm.SubItems.Add(Cb.ToString());
                        break;
                    }
                }
                EtiquetaValoresImporte.Text = Lfx.Types.Formatting.FormatCurrency(Rec.Cobros.ImporteTotal, Lfx.Workspace.Master.CurrentConfig.Moneda.Decimales);
            }

            LabelAgregarValores.Visible = ListaValores.Items.Count == 0 && this.Elemento.Existe == false;
            BotonQuitarValor.Visible    = ListaValores.Items.Count > 0;

            if (ListaValores.Items.Count > 0 && ListaValores.SelectedItems.Count == 0)
            {
                ListaValores.Items[ListaValores.Items.Count - 1].Selected = true;
                ListaValores.Items[ListaValores.Items.Count - 1].Focused  = true;
            }

            ListaValores.EndUpdate();
        }
Пример #39
0
        public static Weapon RandomWeapon(Pg.Level level)
        {
            var weaponsType = typeof(Weapon);
            var weapons = AppDomain.CurrentDomain.GetAssemblies()
                                    .SelectMany(s => s.GetTypes())
                                    .Where(w => weaponsType.IsAssignableFrom(w))
                                    .Where(w => {
                                        var attribute = w.GetCustomAttributes(typeof(Prerequisite), false).FirstOrDefault();
                                        return attribute != null && ((Prerequisite)attribute).MinimumLevel == level;
                                    })
                                    .ToArray();
            if(weapons.Length == 0)
            {
                throw new Exception("Unexpected No Weapon");
            }

            var ix = Dice.Throws(new Dice(weapons.Length)) - 1;

            return (Weapon)Activator.CreateInstance(weapons[ix]);
        }
Пример #40
0
 public EquivalentLevel(Pg.Level level)
 {
     Level = level;        
 }
Пример #41
0
 public OnPrayResult(Pg.Level forLevel)
 {
     ForLevel = forLevel;
 }
Пример #42
0
 public void Register(Pg pg)
 {
     controlledPg = pg;
     CenterOnPlayer();
 }
Пример #43
0
        public OnBadPrayResult(Pg.Level forLevel)
            : base(forLevel)
        {

        }
Пример #44
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string iView = My.getParam("view");
        string type  = My.getParam("type");
        string Code  = My.getParam("Code");
        string id    = My.getParam("id");
        // if ((type == "combotree") && Code == "") return ;

        string    zConnection = My.getMachineName() + "_PricingService";
        string    schema      = iView.Split('.')[0];
        string    table       = iView.Split('.')[1];
        string    comlumn     = iView.Split('.')[2];
        string    sql         = "";
        string    ret         = "";
        JObject   jsonRet     = new JObject();
        DataTable dt          = null;

        // My.print(type);Response.End();
        switch (type)
        {
        case "combotree":
            // sql = string.Format("select [Code], [Parent],[name],lb,rb,Lev, nn from {0}.{1} order by nn;", schema, table);
            if (id != "")
            {
                sql             = string.Format(@"select Code as id, Code + ' - ' + Name as text, case when nc > 1 then 'closed' else 'open' end as state, nc, nn from {0}.{1} where Parent='{2}'", schema, table, id);
                dt              = My.dbRead(sql, zConnection);
                ret             = My.oToJson(dt);
                jsonRet["body"] = JArray.Parse(My.oToJson(dt));
                My.print(jsonRet.ToString());
                Response.End();
            }
            else if (Code != "")
            {
                sql = string.Format(@"
					WITH cte AS (SELECT up.Code, up.Parent, up.Name AS name, up.Lev, up.nc, up.lb, up.rb 
					FROM {0}.{1} AS up INNER JOIN 
					{0}.{1} AS down ON up.lb <= down.lb AND up.rb >= down.rb 
					WHERE (down.Code IN ('{2}'))) 
					SELECT DISTINCT TOP (100) PERCENT h.Code as Code, h.Parent as Parent, h.Code + ' - ' + h.Name as Name, h.Lev as Lev, h.nc, h.nn 
					FROM cte AS cte_1 INNER JOIN 
					{0}.{1} AS h ON cte_1.lb <= h.lb AND cte_1.rb >= h.rb AND cte_1.Lev + 1 = h.Lev OR h.Lev = 1 
					ORDER BY h.nn"                    , schema, table, Code);
                dt  = My.dbRead(sql, zConnection);
                int lev = 1;
                foreach (DataRow dr in dt.Rows)
                {
                    int levN = int.Parse(dr["Lev"].ToString());
                    int nc   = int.Parse(dr["nc"].ToString());
                    if (levN > lev)
                    {
                        ret += ",'children':[";
                    }
                    else if (levN < lev)
                    {
                        ret += "}" + new String(']', lev - levN).Replace("]", "]}") + ",";
                    }
                    else
                    {
                        ret += "},";
                    }
                    ret += "{'id':'" + dr["Code"].ToString() + "'";
                    ret += ",'text':'" + dr["name"].ToString().Replace("\"", "").Replace("'", "") + "'";
                    if (dr["Code"].ToString() == Code)
                    {
                        ret += ",'checked':true";
                    }
                    if (nc > 1)
                    {
                        ret += ",'state': 'closed'";
                    }
                    else
                    {
                        ret += ",'state': 'open'";
                    }
                    lev = int.Parse(dr["Lev"].ToString());
                }
                if (0 < lev)
                {
                    ret += "}" + new String(']', lev - 1).Replace("]", "]}");
                }
                if (ret.Length > 2)
                {
                    ret             = "[" + ret.Substring(2) + "]";
                    jsonRet["body"] = JArray.Parse(ret);
                }
                //My.print(ret);Response.End();

                jsonRet["debug"] = new JValue(sql.Replace("\r", "").Replace("\n", "").Replace("\t", ""));
                // jo = new JObject("","");// JObject.Parse(ret);
                // = "{'body':"+ ret + ",'debug':'"+ sql.Replace("'","") + "'}";
                My.print(jsonRet.ToString());
                Response.End();
            }
            else
            {
                sql              = string.Format(@"select Code as id, Code + ' - ' + Name as text, case when nc > 1 then 'closed' else 'open' end as state, nc, nn from {0}.{1} where Lev=1", schema, table, id);
                dt               = My.dbRead(sql, zConnection);
                ret              = My.oToJson(dt);
                jsonRet["body"]  = JArray.Parse(My.oToJson(dt));
                jsonRet["debug"] = sql;
                My.print(jsonRet.ToString());
                Response.End();
            }
            break;

        case "combogrid":
            ret = Pg.pagination(My.getParam("view"), My.getParam("page"), My.getParam("rows"), My.getParam("sort"), My.getParam("order"), My.getParam("q"), My.getParam("filterRules"), My.getParam("preFilter"));
            My.print(ret);
            break;
        }
    }
Пример #45
0
 public void Unregister(Pg pg)
 {
     controlledPg = null;
 }
Пример #46
0
 public void Register(Pg pg)
 {
     controlledPg = pg;
     ControlledBackpack[0] = pg.Backpack;
     NotifyBuyerGold(pg.MyGold);
 }
Пример #47
0
 public void UnregisterAll()
 {
     controlledPg = null;
     aiCharacters.Clear();
     backpackController.UnregisterAll();
     spellbookController.UnregisterAll();
 }
Пример #48
0
 public void BringUpAndFocus(Pg interactor)
 {
     Register(interactor);
     Notify(ControllerCommand.Merchant_Open);
 }
 public void NotifyLevel(Pg.Level level, God god)
 {
     setTextAndRefresh(  tblPanelNameAndLevel.Controls[_lblLevel], 
                         String.Format("[{0}{1}]", 
                             level.ToString(), 
                             god != null
                             ? String.Format(" of {0}", god.Name)
                             : ""));
 }