Пример #1
0
        public void GetCampfireFromProject()
        {
            Project  p = Project.GetProject(Api, TestBase.Settings.TestProject).Result;
            Campfire c = RunTest(p.GetCampfire(Api));

            Assert.AreEqual(Settings.TestCampfire, c.id);
        }
Пример #2
0
        private static bool Prefix(Fire __instance, Campfire ___m_Campfire, ref bool __result, float ___m_MaxOnTODSeconds, ref float ___m_ElapsedOnTODSeconds)
        {
            var setting = Fire_RVSettings.Instance;

            if (!setting.WindReworked)
            {
                return(true);
            }
            if (!___m_Campfire)
            {
                return(true);
            }


            Vector3 position = __instance.transform.position;

            position.y += 1f;

            if (!Fire_RV.ReworkedFireBlowOut(___m_MaxOnTODSeconds, ___m_ElapsedOnTODSeconds, __instance.GetCurrentTempIncrease()))
            {
                return(false);
            }
            else if (!GameManager.GetWindComponent().IsPositionOccludedFromWind(position))
            {
                __result = true;
            }
            return(true);
        }
Пример #3
0
        public static bool Mobile_SkillCheckDirectTarget(Mobile from, SkillName skillName, object target, double chance)
        {
            Skill skill = from.Skills[skillName];

            if (skill == null)
            {
                return(false);
            }

            if (chance < 0.0)
            {
                return(false);                // Too difficult
            }
            else if (chance >= 1.0)
            {
                return(true);                // No challenge
            }
            CampfireEntry casterEntry = Campfire.GetEntry(from);

            if (casterEntry != null && casterEntry.Safe)
            {
                return(CheckSkill(from, skill, target, chance + 10));
            }
            else
            {
                return(CheckSkill(from, skill, target, chance));
            }
        }
Пример #4
0
        public static bool Mobile_SkillCheckTarget(Mobile from, SkillName skillName, object target, double minSkill, double maxSkill)
        {
            Skill skill = from.Skills[skillName];

            if (skill == null)
            {
                return(false);
            }

            double value = skill.Value;            // - 20 + (from.Hunger + from.Thirst) / 2; //removed hunger by popular request

            CampfireEntry casterEntry = Campfire.GetEntry(from);

            if (casterEntry != null && casterEntry.Safe)
            {
                value += 10;
            }

            if (value < minSkill)
            {
                return(false);                // Too difficult
            }
            else if (value >= maxSkill)
            {
                return(true);                // No challenge
            }
            double chance = (value - minSkill) / (maxSkill - minSkill);

            return(CheckSkill(from, skill, target, chance));
        }
Пример #5
0
        public static bool Mobile_SkillCheckLocation(Mobile from, SkillName skillName, double minSkill, double maxSkill)
        {
            Skill skill = from.Skills[skillName];

            if (skill == null)
            {
                return(false);
            }

            double value = skill.Value;            // - 20 + (from.Hunger + from.Thirst) / 2; //removed hunger by popular request

            if (value < minSkill)
            {
                return(false);                // Too difficult
            }
            else if (value >= maxSkill)
            {
                return(true);                // No challenge
            }
            double chance = (value - minSkill) / (maxSkill - minSkill);

            Point2D       loc         = new Point2D(from.Location.X / LocationSize, from.Location.Y / LocationSize);
            CampfireEntry casterEntry = Campfire.GetEntry(from);

            if (casterEntry != null && casterEntry.Safe)
            {
                return(CheckSkill(from, skill, loc, chance + .10));
            }
            else
            {
                return(CheckSkill(from, skill, loc, chance));
            }
        }
Пример #6
0
        public static bool Mobile_SkillCheckDirectLocation(Mobile from, SkillName skillName, double chance)
        {
            Skill skill = from.Skills[skillName];

            if (skill == null)
            {
                return(false);
            }

            if (chance < 0.0)
            {
                return(false);                // Too difficult
            }
            else if (chance >= 1.0)
            {
                return(true);                // No challenge
            }
            Point2D       loc         = new Point2D(from.Location.X / LocationSize, from.Location.Y / LocationSize);
            CampfireEntry casterEntry = Campfire.GetEntry(from);

            if (casterEntry != null && casterEntry.Safe)
            {
                return(CheckSkill(from, skill, loc, chance + .10));
            }
            else
            {
                return(CheckSkill(from, skill, loc, chance));
            }
        }
Пример #7
0
        public void GetLineFromProject()
        {
            Campfire     c = Campfire.GetCampfire(Api, Settings.TestProject, Settings.TestCampfire).Result;
            CampfireLine l = RunTest(c.GetLine(Api, Settings.TestCampfireLine));

            Assert.AreEqual(Settings.TestCampfireLine, l.id);
        }
Пример #8
0
 public CampfireEntry(PlayerMobile player, Campfire fire)
 {
     Player = player;
     Fire   = fire;
     Start  = Core.Now;
     m_Safe = false;
 }
Пример #9
0
        public override void AddComponents()          /// In this section you can define any item and have it place in the camp x,y,z location.
        {
            ChestLevel1 chest    = new ChestLevel1(); ////Chest level 1-6 This is gonna decide what it looks like.
            FirePit     firepit  = new FirePit();     //// Camps firepit.
            Campfire    campfire = new Campfire();    //// The fire in the pit.

            firepit.ItemID  = 0xFAC;
            campfire.ItemID = 0xDE3;

            TreasureMapChest.Fill(chest, 1);      //// Chest level 1-6 This decides what kinda loot inside.

            AddItem(chest, 4, 4, 0);              //// Adding items to the ground around the spawner. (x,y,z)
            AddItem(firepit, 0, 0, 0);
            AddItem(campfire, 0, 0, 1);

            AddMobile(new Orc(), 15, 2, -2, 0);              /// Adding mobs to the area around the spawner.  (WanderRange,x,y,z)
            AddMobile(new Orc(), 15, -2, -2, 0);
            AddMobile(new OrcCaptain(), 15, 2, 2, 0);
            AddMobile(new OrcishLord(), 15, -2, 2, 0);

            switch (Utility.Random(2))                ////  This is used for adding random mobs to the camp.
            {
            case 0: m_mob = new Ogre(); break;

            case 1: m_mob = new Ettin(); break;
            }

            AddMobile(m_mob, 15, -2, 0, 0);               /// This decides where to place the random mob. (WanderRange,x,y,z)
        }
Пример #10
0
        public override void Process(IConnection connection, string msg)
        {
            try
            {
                Campfire campfire = null;
                double   distance = double.MaxValue;

                foreach (var camp in connection.Player.VisibleCampfires)
                {
                    double dist = camp.Position.DistanceTo(connection.Player.Position);
                    if (dist < distance)
                    {
                        campfire = camp;
                        distance = dist;
                    }
                }

                if (campfire == null)
                {
                    new SpChatMessage("Campfire in visible not found!", ChatType.System).Send(connection);
                    return;
                }

                new SpChatMessage("Unk1: " + campfire.Type, ChatType.System).Send(connection);
                new SpChatMessage("Unk2: " + campfire.Status, ChatType.System).Send(connection);
            }
            catch (Exception ex)
            {
                Logger.WriteLine(LogState.Exception, "AdminEngine: CampfireInfo: " + ex);
            }
        }
Пример #11
0
 private void DistanceToCampfireRecalculated(Campfire campfire, double distance)
 {
     if (distance <= (campfire.Type == 4 ? 200 : 100))
     {
         UsedCampfire = campfire;
     }
 }
Пример #12
0
        /// <summary>
        /// Readies skill, activates fire effect.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="skill"></param>
        /// <param name="packet"></param>
        /// <returns></returns>
        public bool Ready(Creature creature, Skill skill, Packet packet)
        {
            creature.Temp.FireArrow = false;

            // Light arrows (!) on fire if there's a campfire nearby
            if (creature.RightHand != null && creature.RightHand.HasTag("/bow/"))
            {
                creature.Temp.FireArrow = Campfire.GetNearbyCampfire(creature, 500) != null;
            }

            // Add fire arrow effect to arrow
            if (creature.Temp.FireArrow)
            {
                Send.Effect(creature, Effect.FireArrow, true);
            }

            Send.SkillReady(creature, skill.Info.Id);

            // Lock running
            if (!creature.CanRunWithRanged)
            {
                creature.Lock(Locks.Run);
            }

            return(true);
        }
Пример #13
0
        public void GetLines()
        {
            Campfire c = Campfire.GetCampfire(Api, Settings.TestProject, Settings.TestCampfire).Result;
            ApiList <CampfireLine> lines = RunTest(c.GetLines(Api));

            Assert.IsTrue(lines.All(Api).Any(l => l.id == Settings.TestCampfireLine));
        }
Пример #14
0
 public CampfireRegion(Campfire campfire, Region existingRegion) : base("", "", campfire.Map)
 {
     Priority         = Region.HousePriority;
     LoadFromXml      = false;
     m_Campfire       = campfire;
     m_ExistingRegion = existingRegion;
 }
Пример #15
0
    // Use this for initialization
    void Start()
    {
        Tile t = WorldController.Instance.GetTileAt((int)this.transform.position.x, (int)this.transform.position.y);

        campfire = new Campfire(t, maxPop);
        WorldController.Instance.SetWalkable((int)this.transform.position.x, (int)this.transform.position.y, 0);
    }
Пример #16
0
 public CampfireEntry(PlayerMobile player, Campfire fire)
 {
     Player = player;
     Fire   = fire;
     Start  = DateTime.UtcNow;
     m_Safe = false;
 }
Пример #17
0
        public void Target(Mobile m)
        {
            if (!Caster.CanSee(m))
            {
                Caster.SendLocalizedMessage(500237);                   // Target can not be seen.
            }
            else if (m.IsDeadBondedPet)
            {
                Caster.SendLocalizedMessage(1060177);                   // You cannot heal a creature that is already dead!
            }
            else if (m is BaseCreature && ((BaseCreature)m).IsAnimatedDead)
            {
                Caster.SendLocalizedMessage(1061654);                   // You cannot heal that which is not alive.
            }
            else if (m is Golem)
            {
                Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2, 500951);                   // You cannot heal that.
            }
            else if (m.Poisoned || Server.Items.MortalStrike.IsWounded(m))
            {
                Caster.LocalOverheadMessage(MessageType.Regular, 0x22, (Caster == m) ? 1005000 : 1010398);
            }
            else if (CheckBSequence(m))
            {
                SpellHelper.Turn(Caster, m);

                int           toHeal;
                CampfireEntry casterEntry = Campfire.GetEntry(Caster);

                if (Core.AOS)
                {
                    toHeal  = Caster.Skills.Magery.Fixed / 120;
                    toHeal += Utility.RandomMinMax(1, 4);

                    if (Core.SE && Caster != m)
                    {
                        toHeal = (int)(toHeal * 1.5);
                    }
                }
                else
                {
                    toHeal  = (int)(Caster.Skills[SkillName.Magery].Value * 0.1);
                    toHeal += Utility.Random(1, 5);
                }
                if (casterEntry != null && casterEntry.Safe)
                {
                    toHeal += 2;
                }
                toHeal += (int)Caster.Skills[SkillName.Healing].Value / 24;
                //m.Heal( toHeal, Caster );
                Spellweaving.ArcaneEmpowermentSpell.AddHealBonus(Caster, ref toHeal);
                SpellHelper.Heal(toHeal, m, Caster);

                m.FixedParticles(0x376A, 9, 32, 5005, EffectLayer.Waist);
                m.PlaySound(0x1F2);
            }

            FinishSequence();
        }
Пример #18
0
 private static void Postfix(Campfire __instance, Fire ___m_Fire, ref string __result)
 {
     if (___m_Fire.GetRemainingLifeTimeSeconds() == 0)
     {
         __result += "\n(" + ___m_Fire.GetHeatIncreaseText() + ")";
     }
     //if (___m_Fire.m_HeatSource.IsTurnedOn() && ___m_Fire.GetRemainingLifeTimeSeconds() == 0) __result += "\n(" + ___m_Fire.GetHeatIncreaseText() + ")";
 }
Пример #19
0
 public void OpenCampfire(Campfire c)
 {
     campfire = c;
     InitializeCampfire();
     campfire.OnItemChangedCallback += UpdateUI;
     campfire.OnCookingCallback     += UpdateProgressBar;
     GameInterfaceManager.Instance.ToggleGameInterface(GameInterface.Campfire);
 }
Пример #20
0
 void Start()
 {
     cam        = Camera.main;
     actionBar  = FindObjectOfType <ActionBar>();
     campfire   = FindObjectOfType <Campfire>();
     envDetails = FindObjectOfType <EnvDetails>();
     fireSound  = GetComponentInParent <AudioSource>();
     //Cursor.lockState = CursorLockMode.Locked;
 }
Пример #21
0
    private void CreateCampfire(MazeCell cell)
    {
        Campfire campfire = Instantiate(campfirePrefab) as Campfire;

        campfire.name                    = "Campfire" + campfireCount;
        campfire.transform.parent        = cell.transform;
        campfire.transform.localPosition = new Vector3(0f, -0.04f, 0f);
        campfireCount++;
    }
Пример #22
0
        private void Handler(Campfire campfire, bool roasting)
        {
            if (campfire == null)
            {
                SendEvent(CreateMessage(-1, roasting));
                return;
            }
            var qsbObj = QSBWorldSync.GetWorldFromUnity <QSBCampfire, Campfire>(campfire);

            SendEvent(CreateMessage(qsbObj.ObjectId, roasting));
        }
Пример #23
0
    private void Start()
    {
        gm       = FindObjectOfType <GameManager>();
        campfire = FindObjectOfType <Campfire>();

        if (PlayerPrefs.GetInt("continued") == 1)
        {
            LoadWorld();
        }

        goldText.text = $"{gm.gold}";
    }
Пример #24
0
        public override void Action()
        {
            if (Player.Controller is DeathController)
            {
                return;
            }

            if (UsedCampfire != null)
            {
                if (UsedCampfire.Instance != Player.Instance ||
                    UsedCampfire.Position.FastDistanceTo(Player.Position) > (UsedCampfire.Type == 4 ? 200 : 100))
                {
                    UsedCampfire = null;

                    if (Player.PlayerMode == PlayerMode.Relax)
                    {
                        Player.PlayerMode = PlayerMode.Normal;
                        Global.VisibleService.Send(Player, new SpCharacterState(Player));
                    }
                }
                else if (Player.PlayerMode == PlayerMode.Normal)
                {
                    Player.PlayerMode = PlayerMode.Relax;
                    Global.VisibleService.Send(Player, new SpCharacterState(Player));
                }
            }

            long now = RandomUtilities.GetCurrentMilliseconds();

            if (Player.Controller is BattleController)
            {
                LastBattleUts = now;
            }

            while (now >= NextRegenUts)
            {
                Regenerate();
                NextRegenUts += Player.Controller is BattleController ? 5000 : 2000;
            }

            while (now > NextDistressUts)
            {
                int timeout = (Player.LifeStats.Stamina > 100) ? 90000 : 60000;

                if (Player.Controller is BattleController)
                {
                    timeout -= 30000;
                }

                Distress();
                NextDistressUts += timeout;
            }
        }
Пример #25
0
        static bool Prefix(Panel_FireStart __instance, Campfire ___m_CampFireInstance, FireStarterItem ___m_KeroseneAccelerant, FireManager ___m_FireManager, bool skipResearchItemCheck = false)
        {
            var traverseInstance = Traverse.Create(__instance);

            traverseInstance.Field("m_FireManager").SetValue(GameManager.GetFireManagerComponent());

            var selectedFireStarter = traverseInstance.Method("GetSelectedFireStarter").GetValue <FireStarterItem>();
            var selectedTinder      = traverseInstance.Method("GetSelectedTinder").GetValue <FuelSourceItem>();
            var selectedFuelSource  = traverseInstance.Method("GetSelectedFuelSource").GetValue <FuelSourceItem>();
            var selectedAccelerant  = traverseInstance.Method("GetSelectedAccelerant").GetValue <FireStarterItem>();

            if (___m_CampFireInstance && ___m_CampFireInstance.TooWindyToStart())
            {
                GameAudioManager.PlayGUIError();
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_Itstoowindytostartafirethere"), false);
                return(false);
            }
            if (selectedFireStarter == null || (GameManager.GetSkillFireStarting().TinderRequired() && selectedTinder == null) || selectedFuelSource == null)
            {
                GameAudioManager.PlayGUIError();
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_Insufficientmaterialstocreatefire"), false);
                return(false);
            }

            if (selectedFireStarter.m_RequiresSunLight && !traverseInstance.Method("HasDirectSunlight").GetValue <bool>())
            {
                GameAudioManager.PlayGUIError();
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_Magnifyinglensrequiresdirectsunlight"), false);
                return(false);
            }
            if (!skipResearchItemCheck)
            {
                ResearchItem component = selectedFuelSource.GetComponent <ResearchItem>();
                if (component != null && !component.IsResearchComplete())
                {
                    Panel_Confirmation.CallbackDelegate forceBurnResearchItem = () => traverseInstance.Method("ForceBurnResearchItem").GetValue();
                    InterfaceManager.m_Panel_Confirmation.ShowBurnResearchNotification(forceBurnResearchItem);
                    return(false);
                }
            }
            if (selectedAccelerant != null && selectedAccelerant == ___m_KeroseneAccelerant)
            {
                GameManager.GetPlayerManagerComponent().DeductLiquidFromInventory(GameManager.GetFireManagerComponent().m_KeroseneLitersAccelerant, GearLiquidTypeEnum.Kerosene);
            }
            float percentChanceSuccess = TinderHelper.CalculateFireStartSuccess(selectedFireStarter, selectedTinder, selectedFuelSource, selectedAccelerant);

            ___m_FireManager.PlayerStartFire(___m_CampFireInstance, selectedFireStarter, selectedTinder, selectedFuelSource, selectedAccelerant, percentChanceSuccess);
            __instance.Enable(false);
            GameAudioManager.PlayGuiConfirm();
            return(false);
        }
Пример #26
0
        private static void Handler(Campfire campfire, bool roasting)
        {
            if (PlayerTransformSync.LocalInstance)
            {
                if (campfire == null)
                {
                    new EnterExitRoastingMessage(-1, roasting).Send();
                    return;
                }

                var qsbObj = campfire.GetWorldObject <QSBCampfire>();
                new EnterExitRoastingMessage(qsbObj.ObjectId, roasting).Send();
            }
        }
Пример #27
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

            Point3D fireLoc = new Point3D(from.X + 5, from.Y + 2, from.Z);

            bool deconstruct = info.IsSwitched(2);
            bool logout      = info.IsSwitched(3);

            if (deconstruct)
            {
                m_Bedroll.Delete();

                from.AddToBackpack(new TravelTent());

                Campfire fire = new Campfire();
                fire.Status = CampfireStatus.Off;
                fire.MoveToWorld(fireLoc, from.Map);
            }

            if (logout)
            {
                m_Bedroll.Delete();

                if (from.Backpack != null && from.Backpack.GetAmount(typeof(TentValidator)) > 0)
                {
                    from.Backpack.ConsumeTotal(typeof(TentValidator), 1);
                }

                from.AddToBackpack(new TravelTent());

                Campfire fire = new Campfire();
                fire.Status = CampfireStatus.Off;
                fire.MoveToWorld(fireLoc, from.Map);

                ((PlayerMobile)from).BedrollLogout = true;
                state.Dispose();
            }

            switch (info.ButtonID)
            {
            default:
            case 0:
            {
                from.CloseGump(typeof(TentManagementGump));
                break;
            }
            }
        }
Пример #28
0
    private bool CanExtinguish()
    {
        // Checking if the player has Full Bucket Equiped
        if (_inventory.HandEquipment.IsOccupied && _inventory.HandEquipment.InvSlotContent.Item.Type == Item.ItemType.FullBucket)
        {
            // TODO: Select the closest object to the player
            foreach (GameObject col in AllInstructionsObjectsColliders)
            {
                if (col.transform.tag == "Resource Mine")
                {
                    NearbyResourceMine = col.GetComponent <ResourceMine>();
                    if (NearbyResourceMine.IsOnFire)
                    {
                        return(true);
                    }
                }
                else if (col.transform.tag == "Resource Drop")
                {
                    NearbyResourceDrop = col.GetComponent <ResourceDrop>();
                    if (NearbyResourceDrop.IsOnFire)
                    {
                        return(true);
                    }
                }
                else if (col.transform.tag == "Campfire")
                {
                    NearbyCampfire = col.GetComponent <Campfire>();
                    if (NearbyCampfire.IsOnFire)
                    {
                        return(true);
                    }
                }
            }

            /*if (NearbyResourceMine != null && NearbyResourceMine.IsOnFire)
             * {
             *  return true;
             * }
             * else if (NearbyResourceDrop != null && NearbyResourceDrop.IsOnFire)
             * {
             *  return true;
             * }
             * else if (NearbyCampfire != null && NearbyResourceDrop.IsOnFire)
             * {
             *  return true;
             * }*/
        }
        return(false);
    }
Пример #29
0
    void Update()
    {
        if (player.paused)
        {
            return;
        }

        Temp = globalBaseTemp + (10 - treeChange) + (5 - bushChange) + Mathf.Sqrt(Campfire.NumCampfires());

        Rabbit.MAXBUNNIES = 20 * (int)((Tree.TreeRatio() + Bush.BushRatio()) / 2);
        Herd.MaxHerdSize  = 15 * (int)((Tree.TreeRatio() + Bush.BushRatio()) / 2);

        if (Temp > 27)
        {
            if (!desertMatChanged)
            {
                Debug.Log("Global temp at: " + Temp + " desertification beginning");
                level.GetComponent <Renderer>().material = desertMat;
                desertMatChanged         = true;
                water.transform.position = new Vector3(water.transform.position.x, dryWaterLevel, water.transform.position.z);
            }

            if (!ashMatChanged && Temp > 35)
            {
                Debug.Log("Global temp at: " + Temp + " desertification severe");
                level.GetComponent <Renderer>().material = ashMat;
                ashMatChanged            = true;
                water.transform.position = new Vector3(water.transform.position.x, emptyWaterLevel, water.transform.position.z);
            }

            if (Random.Range(0f, 1f) > 0.5f)
            {
                if (trees.transform.childCount > 0)
                {
                    trees.transform.GetChild((int)Random.Range(0, trees.transform.childCount)).GetComponent <Health>().ApplyDamage(Random.Range(0, (Temp - 27) / 10));
                }
            }
            else
            {
                if (bushes.transform.childCount > 0)
                {
                    bushes.transform.GetChild((int)Random.Range(0, bushes.transform.childCount)).GetChild(0).GetComponent <Health>().ApplyDamage(Random.Range(0, (Temp - 27) / 10));
                }
            }
        }

        treeChange = 10 * Tree.TreeRatio();
        bushChange = 5 * Bush.BushRatio();
    }
Пример #30
0
        public void CreateAndDeleteLine()
        {
            if (!Settings.ModifyTests)
            {
                return;
            }
            Campfire               c     = Campfire.GetCampfire(Api, Settings.TestProject, Settings.TestCampfire).Result;
            CampfireLine           l     = c.CreateLine(Api, "Test Campfire Line").Result;
            ApiList <CampfireLine> lines = RunTest(c.GetLines(Api));

            Assert.IsTrue(lines.All(Api).Any(ln => ln.id == l.id));
            RunTest(l.Delete(Api));
            lines = RunTest(c.GetLines(Api));
            Assert.IsFalse(lines.All(Api).Any(ln => ln.id == l.id));
        }
Пример #31
0
        static bool DoDice(Campfire.Room room, Campfire.Message msg)
        {
            if (!msg.UserID.HasValue)
            {
                return true;
            }

            List<string> diceSpecs = new List<string>();
            string description = null;

            string[] diceParams = msg.Body.Remove(0, 5).Trim().Split(new char[] { ' ', '\t' });
            if (diceParams.Length == 0)
            {
                return true;
            }

            for (int i = 0; i < diceParams.Length; ++i)
            {
                if (DiceRoll.LooksLikeASpec(diceParams[i]))
                {
                    diceSpecs.Add(diceParams[i]);
                }
                else
                {
                    if (i == 0)
                    {
                        return true;
                    }

                    description = diceParams.Skip(i).Aggregate((first, second) => first + " " + second);
                    break;
                }
            }

            StringBuilder response = new StringBuilder();

            foreach (string diceSpec in diceSpecs)
            {
                if (response.Length != 0)
                {
                    response.Append("\r\n");
                }

                response.Append("DICE (");
                response.Append(msg.User.Name);
                if (description != null)
                {
                    response.Append(' ');
                    response.Append(description);
                }
                response.Append(") ");
                response.Append(" ==> ");

                try
                {
                    DiceRoll roll = m_dice.Roll(diceSpec);
                    response.Append(roll.Description);
                }
                catch (ArgumentException)
                {
                    return true;
                }
            }

            room.Speak(diceSpecs.Count() == 1 ? "TextMessage" : "PasteMessage", response.ToString());
            return true;
        }
Пример #32
0
        static bool DoExit(Campfire.Room room, Campfire.Message msg)
        {
            if (msg.UserID.HasValue && (msg.UserID.Value == RYAN_USER_ID))
            {
                room.Speak("TextMessage", "Leaving.");
                return false;
            }

            return true;
        }
Пример #33
0
        static bool DoEclipsePhaseDice(Campfire.Room room, Campfire.Message msg)
        {
            if (!msg.UserID.HasValue)
            {
                return true;
            }

            int targetNum;
            string description = null;

            string[] diceParams = msg.Body.Remove(0, 3).Trim().Split(new char[] { ' ', '\t' });
            if (diceParams.Length == 0)
            {
                return true;
            }

            try
            {
                targetNum = Convert.ToInt32(diceParams[0]);
            }
            catch (FormatException)
            {
                return true;
            }

            if (targetNum < 0)
            {
                return true;
            }

            if (diceParams.Length > 1)
            {
                description = diceParams.Skip(1).Aggregate((first, second) => first + " " + second);
            }

            StringBuilder response = new StringBuilder("EPD (");
            response.Append(msg.User.Name);
            if (description != null)
            {
                response.Append(' ');
                response.Append(description);
            }
            response.Append(") ");
            response.Append(" ==> ");

            DiceRoll roll = m_dice.Roll(1,100,0);

            response.Append(GenerateEclipsePhaseResult(roll.Value, targetNum));

            room.Speak("TextMessage", response.ToString());
            return true;
        }
Пример #34
0
        static bool MessageCallback(Campfire.Room room, Campfire.Message msg)
        {
            if (msg.Type == "TextMessage")
            {
                if (msg.Body.StartsWith("!roll") || msg.Body.StartsWith("!dice"))
                {
                    return DoDice(room, msg);
                }
                else if (msg.Body.StartsWith("!ep"))
                {
                    return DoEclipsePhaseDice(room, msg);
                }
                else if (msg.Body.StartsWith("!DEBUG_EPTEST"))
                {
                    StringBuilder response = new StringBuilder();
                    response.Append(GenerateEclipsePhaseResult(0, 50)); response.Append("\r\n");
                    response.Append(GenerateEclipsePhaseResult(20, 50)); response.Append("\r\n");
                    response.Append(GenerateEclipsePhaseResult(22, 50)); response.Append("\r\n");
                    response.Append(GenerateEclipsePhaseResult(40, 50)); response.Append("\r\n");
                    response.Append(GenerateEclipsePhaseResult(44, 50)); response.Append("\r\n");
                    response.Append(GenerateEclipsePhaseResult(50, 50)); response.Append("\r\n");
                    response.Append(GenerateEclipsePhaseResult(60, 50)); response.Append("\r\n");
                    response.Append(GenerateEclipsePhaseResult(66, 50)); response.Append("\r\n");
                    response.Append(GenerateEclipsePhaseResult(80, 50)); response.Append("\r\n");
                    response.Append(GenerateEclipsePhaseResult(88, 50)); response.Append("\r\n");
                    response.Append(GenerateEclipsePhaseResult(99, 50)); response.Append("\r\n");
                    room.Speak("PasteMessage", response.ToString());
                    return true;
                }
                else if (msg.Body.StartsWith("!die"))
                {
                    return DoExit(room, msg);
                }
                else
                {
                    Console.WriteLine("RECV: {0} > {1}", msg.UserID.HasValue ? msg.User.Name : "", msg.Body);
                }
            }

            return true;
        }