Пример #1
0
            public string GetName(
                GameSession game,
                int playerid,
                ShipClass shipclass,
                IEnumerable <string> checknames = null)
            {
                string name = "";

                foreach (List <KeyValuePair <string, string> > list in this.Lists)
                {
                    if (list.Any <KeyValuePair <string, string> >((Func <KeyValuePair <string, string>, bool>)(x =>
                    {
                        if (!(x.Key == ""))
                        {
                            return(x.Key.ToLower().Contains(shipclass.ToString().ToLower()));
                        }
                        return(true);
                    })))
                    {
                        name += string.Format("{0}", (object)NamesPool.Choose(list.Where <KeyValuePair <string, string> >((Func <KeyValuePair <string, string>, bool>)(x =>
                        {
                            if (!(x.Key == ""))
                            {
                                return(x.Key.ToLower().Contains(shipclass.ToString().ToLower()));
                            }
                            return(true);
                        })).Select <KeyValuePair <string, string>, string>((Func <KeyValuePair <string, string>, string>)(x => x.Value)).ToList <string>()));
                    }
                }
                List <string> usedNames = new List <string>();

                usedNames.AddRange(game.GameDatabase.GetShipInfos(true).Where <ShipInfo>((Func <ShipInfo, bool>)(x => x.DesignInfo.PlayerID == playerid)).Select <ShipInfo, string>((Func <ShipInfo, string>)(x => x.ShipName)));
                foreach (InvoiceInfo invoiceInfo in game.GameDatabase.GetInvoiceInfosForPlayer(playerid))
                {
                    foreach (BuildOrderInfo buildOrderInfo in game.GameDatabase.GetBuildOrdersForInvoiceInstance(invoiceInfo.ID))
                    {
                        usedNames.Add(buildOrderInfo.ShipName);
                    }
                }
                if (checknames != null)
                {
                    usedNames.AddRange(checknames);
                }
                NamesPool.AppendDuplicate(ref name, ref usedNames);
                return(name);
            }
Пример #2
0
    public JSONObject jsonify()
    {
        JSONObject json = new JSONObject(JSONObject.Type.OBJECT);

        json.AddField("class", shipClass.ToString());
        json.AddField("speed", speed);

        JSONObject facilities = new JSONObject(JSONObject.Type.ARRAY);

        foreach (ManagerProtocol.FacilityShortcut key in shipFacilities.Keys)
        {
            JSONObject record = new JSONObject(JSONObject.Type.OBJECT);
            record.AddField("key", key.ToString());
            record.AddField("value", shipFacilities[key].jsonify());
            facilities.Add(record);
        }
        json.AddField("facilities", facilities);

        return(json);
    }
Пример #3
0
    /// <summary>
    /// Server-side function to set the ship class, which determines base stats
    /// </summary>
    /// <param name="new_class">Class to set ship class to</param>
    public void SetClass(ShipClass new_class)
    {
        Class = new_class;
        ShipType = new_class.ToString();

        switch(new_class)
        {
            case ShipClass.Pinnace:
                HullHealth = MaxHullHealth = 50;
                SailHealth = MaxSailHealth = 50;
                CargoSpace = 15;
                Cannons = MaxCannons = 4;
                Speed = FullSpeed = 5;
                CrewNeeded = 6;
                DodgeChance = 40;
                Price = 50;
                break;
            case ShipClass.Sloop:
                HullHealth = MaxHullHealth = 60;
                SailHealth = MaxSailHealth = 70;
                CargoSpace = 35;
                Cannons = MaxCannons = 6;
                Speed = FullSpeed = 5;
                CrewNeeded = 9;
                DodgeChance = 35;
                Price = 100;
                break;
            case ShipClass.Barque:
                HullHealth = MaxHullHealth = 80;
                SailHealth = MaxSailHealth = 80;
                CargoSpace = 45;
                Cannons = MaxCannons = 8;
                Speed = FullSpeed = 4;
                CrewNeeded = 11;
                DodgeChance = 30;
                Price = 150;
                break;
            case ShipClass.Brig:
                HullHealth = MaxHullHealth = 120;
                SailHealth = MaxSailHealth = 100;
                CargoSpace = 100;
                Cannons = MaxCannons = 10;
                Speed = FullSpeed = 3;
                CrewNeeded = 14;
                DodgeChance = 25;
                Price = 200;
                break;
            case ShipClass.Merchantman:
                HullHealth = MaxHullHealth = 120;
                SailHealth = MaxSailHealth = 100;
                CargoSpace = 150;
                Cannons = MaxCannons = 8;
                Speed = FullSpeed = 3;
                CrewNeeded = 12;
                DodgeChance = 25;
                Price = 200;
                break;
            case ShipClass.MerchantGalleon:
                HullHealth = MaxHullHealth = 200;
                SailHealth = MaxSailHealth = 200;
                CargoSpace = 450;
                Cannons = MaxCannons = 12;
                Speed = FullSpeed = 2;
                CrewNeeded = 19;
                DodgeChance = 15;
                ShipType = "Merchant Galleon";
                Price = 500;
                break;
            case ShipClass.CombatGalleon:
                HullHealth = MaxHullHealth = 250;
                SailHealth = MaxSailHealth = 250;
                CargoSpace = 400;
                Cannons = MaxCannons = 24;
                Speed = FullSpeed = 2;
                CrewNeeded = 31;
                DodgeChance = 15;
                ShipType = "Combat Galleon";
                Price = 800;
                break;
            case ShipClass.Frigate:
                HullHealth = MaxHullHealth = 300;
                SailHealth = MaxSailHealth = 300;
                CargoSpace = 600;
                Cannons = MaxCannons = 32;
                Speed = FullSpeed = 1;
                CrewNeeded = 43;
                DodgeChance = 10;
                Price = 1500;
                break;
        }
    }
Пример #4
0
    /// <summary>
    /// Server-side function to set the ship class, which determines base stats
    /// </summary>
    /// <param name="new_class">Class to set ship class to</param>
    public void SetClass(ShipClass new_class)
    {
        Class    = new_class;
        ShipType = new_class.ToString();

        switch (new_class)
        {
        case ShipClass.Pinnace:
            HullHealth  = MaxHullHealth = 50;
            SailHealth  = MaxSailHealth = 50;
            CargoSpace  = 15;
            Cannons     = MaxCannons = 4;
            Speed       = FullSpeed = 5;
            CrewNeeded  = 6;
            DodgeChance = 40;
            Price       = 50;
            break;

        case ShipClass.Sloop:
            HullHealth  = MaxHullHealth = 60;
            SailHealth  = MaxSailHealth = 70;
            CargoSpace  = 35;
            Cannons     = MaxCannons = 6;
            Speed       = FullSpeed = 5;
            CrewNeeded  = 9;
            DodgeChance = 35;
            Price       = 100;
            break;

        case ShipClass.Barque:
            HullHealth  = MaxHullHealth = 80;
            SailHealth  = MaxSailHealth = 80;
            CargoSpace  = 45;
            Cannons     = MaxCannons = 8;
            Speed       = FullSpeed = 4;
            CrewNeeded  = 11;
            DodgeChance = 30;
            Price       = 150;
            break;

        case ShipClass.Brig:
            HullHealth  = MaxHullHealth = 120;
            SailHealth  = MaxSailHealth = 100;
            CargoSpace  = 100;
            Cannons     = MaxCannons = 10;
            Speed       = FullSpeed = 3;
            CrewNeeded  = 14;
            DodgeChance = 25;
            Price       = 200;
            break;

        case ShipClass.Merchantman:
            HullHealth  = MaxHullHealth = 120;
            SailHealth  = MaxSailHealth = 100;
            CargoSpace  = 150;
            Cannons     = MaxCannons = 8;
            Speed       = FullSpeed = 3;
            CrewNeeded  = 12;
            DodgeChance = 25;
            Price       = 200;
            break;

        case ShipClass.MerchantGalleon:
            HullHealth  = MaxHullHealth = 200;
            SailHealth  = MaxSailHealth = 200;
            CargoSpace  = 450;
            Cannons     = MaxCannons = 12;
            Speed       = FullSpeed = 2;
            CrewNeeded  = 19;
            DodgeChance = 15;
            ShipType    = "Merchant Galleon";
            Price       = 500;
            break;

        case ShipClass.CombatGalleon:
            HullHealth  = MaxHullHealth = 250;
            SailHealth  = MaxSailHealth = 250;
            CargoSpace  = 400;
            Cannons     = MaxCannons = 24;
            Speed       = FullSpeed = 2;
            CrewNeeded  = 31;
            DodgeChance = 15;
            ShipType    = "Combat Galleon";
            Price       = 800;
            break;

        case ShipClass.Frigate:
            HullHealth  = MaxHullHealth = 300;
            SailHealth  = MaxSailHealth = 300;
            CargoSpace  = 600;
            Cannons     = MaxCannons = 32;
            Speed       = FullSpeed = 1;
            CrewNeeded  = 43;
            DodgeChance = 10;
            Price       = 1500;
            break;
        }
    }