Example #1
0
    void Start()
    {
        _moduleId = _moduleIdCounter++;

        PanstwaInfo = JsonConvert.DeserializeObject <List <Panstwa> >(jsonInfo.ToString());

        int main = numbers[Random.Range(0, numbers.Count)];

        mainPanstwa        = PanstwaInfo[main];
        mainPanstwa.KrajID = main;
        numbers.Remove(main);

        for (int i = 0; i < 7; i++)
        {
            int id = numbers[Random.Range(0, numbers.Count)];
            countries.Add(PanstwaInfo[id]);
            countries[i].KrajID = id;
            numbers.Remove(id);
        }

        order  = getOrder(mainPanstwa, countries);
        number = Random.Range(1, 8);

        mainFlag.material.mainTexture = flags[mainPanstwa.KrajID];
        updateScreen();

        Debug.LogFormat("[Flags PL #{0}] Main Display: {1}", _moduleId, mainPanstwa.NazwaKraju);
        Debug.LogFormat("[Flags PL #{0}] Flag List: {1}", _moduleId, string.Join(", ", countries.Select(x => x.NazwaKraju).ToArray()));
        Debug.LogFormat("[Flags PL #{0}] Order Rule: {1}", _moduleId, getRule(mainPanstwa, countries));
        Debug.LogFormat("[Flags PL #{0}] Order: {1}", _moduleId, string.Join(", ", order.Select(x => x.NazwaKraju).ToArray()));
        Debug.LogFormat("[Flags PL #{0}] Answer: {1} (#{2})", _moduleId, order[number - 1].NazwaKraju, number);
    }
Example #2
0
    private Panstwa[] getOrder(Panstwa main, List <Panstwa> list)
    {
        // BUT if there is an unlit BOB, and the serial number contains any characters from the phrase "WHITE FLAG"
        // while France is in the 7 flags, ignore all above instuctions and submit France four times.
        if (bombInfo.GetSerialNumber().Any("WHITEFLAG".Contains) && bombInfo.IsIndicatorOff(KMBI.KnownIndicatorLabel.BOB) &&
            list.Contains(PanstwaInfo[13]))
        {
            return(Enumerable.Repeat(PanstwaInfo[13], 7).ToArray());
        }

        // If the main Panstwa is in North America, and there are no lit indicators,
        // sort the 7 flags by their Panstwa name in alphabetical order.
        if (main.Kontynent == "North America" && bombInfo.GetOnIndicators().Count() == 0)
        {
            return(list.OrderBy(x => x.NazwaKraju).ToArray());
        }

        // Otherwise, if the main Panstwa's dial code is higher than 100, and there is an RJ-45 port,
        // sort the 7 flags by their dial code in numerical order.
        if (main.KrajKod > 100 && bombInfo.IsPortPresent(KMBI.KnownPortType.RJ45))
        {
            return(list.OrderBy(x => x.KrajKod).ThenBy(x => x.NazwaKraju).ToArray());
        }

        // Otherwise, if the main Panstwa's name contains the last letter of its Waluta,
        // sort the 7 flags by their ISO code in alphabetical order.
        if (main.NazwaKraju.ToUpperInvariant().Contains(main.Waluta[2]))
        {
            return(list.OrderBy(x => x.KrajISO).ToArray());
        }

        // Otherwise, if the main Panstwa's Stolica has more than 9 letters,
        // sort the 7 flags by their Stolica in alphabetical order.
        if (main.Stolica.Count(char.IsLetter) > 9)
        {
            return(list.OrderBy(x => x.Stolica).ToArray());
        }

        // Otherwise, if the main Panstwa is in Europe, and its Waluta is not EUR,
        // sort the 7 flags by their Kontynent in alphabetical order.
        if (main.Kontynent == "Europe" && main.Waluta != "EUR")
        {
            return(list.OrderBy(x => x.Kontynent).ThenBy(x => x.NazwaKraju).ToArray());
        }

        // Otherwise, if there is a Panstwa in the 7 flags with the same Kontynent as the main Panstwa's,
        // sort the 7 flags by their Waluta in alphabetical order.
        if (list.Find(x => x.Kontynent == main.Kontynent) != null)
        {
            return(list.OrderBy(x => x.Waluta).ThenBy(x => x.NazwaKraju).ToArray());
        }

        // Otherwise, sort the 7 flags by their Panstwa name in alphabetical order.
        return(list.OrderBy(x => x.NazwaKraju).ToArray());
    }