Konami Code in C#

后端 未结 11 2144
执笔经年
执笔经年 2020-12-07 19:07

I am looking to have a C# application implement the Konami Code to display an Easter Egg. http://en.wikipedia.org/wiki/Konami_Code

What is the best way to do this?<

11条回答
  •  旧巷少年郎
    2020-12-07 20:05

    I recommend you implement as a list of search events and a "capture" reference pointer to elements of that list.

    Conceptually, you start the capture pointer to the first element of the search list. If the very next event matches the search element, the capture pointer is incremented to the next element. Otherwise, it is reset to the beginning.

    If the pointer is incremented past the last element, you have a full match.

提交回复
热议问题