コード例 #1
0
        private static byte GetAdjustedFriendship(Event e, byte curFriendship, ItemType caughtBall, MapSection metLocation, ItemType item
#if DEBUG
                                                  , string nickname
#endif
                                                  )
        {
            if (e == Event.Walking && PBEDataProvider.GlobalRandom.RandomBool())
            {
                return(curFriendship); // 50% chance walking boosts
            }

            int friendshipLevel = 0;
            int friendship      = curFriendship;

            if (friendship >= 100)
            {
                friendshipLevel++;
            }
            if (friendship >= 200)
            {
                friendshipLevel++;
            }

            int mod = GetEventBonuses(e)[friendshipLevel];

            if (mod > 0)
            {
                if (caughtBall == ItemType.LuxuryBall)
                {
                    mod++;
                }
                if (metLocation == Overworld.GetCurrentLocation())
                {
                    mod++;
                }
                if (item == ItemType.SootheBell)
                {
                    mod = (int)(mod * 1.5f);
                }
            }
            friendship += mod;
            if (friendship < 0)
            {
                friendship = 0;
            }
            if (friendship > byte.MaxValue)
            {
                friendship = byte.MaxValue;
            }
#if DEBUG
            Console.WriteLine("{0} friendship adjustment: {1}_{2}", nickname, e, mod);
#endif
            return((byte)friendship);
        }