about summary refs log tree commit diff stats
path: root/apworld/__init__.py
blob: 54f870f594edfca15de81d2922f8dffdd9505959 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
"""
Archipelago init file for Lingo 2
"""
from BaseClasses import ItemClassification, Item, Tutorial
from worlds.AutoWorld import WebWorld, World
from .items import Lingo2Item
from .options import Lingo2Options
from .player_logic import Lingo2PlayerLogic
from .regions import create_regions
from .static_logic import Lingo2StaticLogic
from .version import APWORLD_VERSION


class Lingo2WebWorld(WebWorld):
    rich_text_options_doc = True
    theme = "grass"
    tutorials = [Tutorial(
        "Multiworld Setup Guide",
        "A guide to playing Lingo 2 with Archipelago.",
        "English",
        "en_Lingo_2.md",
        "setup/en",
        ["hatkirby"]
    )]


class Lingo2World(World):
    """
    Lingo 2 is a first person indie puzzle game where you solve word puzzles in a labyrinthe world. Compared to its
    predecessor, Lingo 2 has new mechanics, more areas, and a unique progression system where you have to unlock letters
    before using them in puzzle solutions.
    """
    game = "Lingo 2"
    web = Lingo2WebWorld()

    topology_present = True

    options_dataclass = Lingo2Options
    options: Lingo2Options

    static_logic = Lingo2StaticLogic()
    item_name_to_id = static_logic.item_name_to_id
    location_name_to_id = static_logic.location_name_to_id
    item_name_groups = static_logic.item_name_groups
    location_name_groups = static_logic.location_name_groups

    player_logic: Lingo2PlayerLogic

    def generate_early(self):
        self.player_logic = Lingo2PlayerLogic(self)

    def create_regions(self):
        create_regions(self)

        from Utils import visualize_regions

        visualize_regions(self.multiworld.get_region("Menu", self.player), "my_world.puml")

    def create_items(self):
        pool = [self.create_item(name) for name in self.player_logic.real_items]

        total_locations = sum(len(locs) for locs in self.player_logic.locations_by_room.values())

        item_difference = total_locations - len(pool)
        for i in range(0, item_difference):
            pool.append(self.create_item(self.get_filler_item_name()))

        self.multiworld.itempool += pool

    def create_item(self, name: str) -> Item:
        return Lingo2Item(name, ItemClassification.filler if name == self.get_filler_item_name() else
                                ItemClassification.progression,
                          self.item_name_to_id.get(name), self.player)

    def set_rules(self):
        self.multiworld.completion_condition[self.player] = lambda state: state.has("Victory", self.player)

    def fill_slot_data(self):
        slot_options = [
            "cyan_door_behavior",
            "daedalus_roof_access",
            "keyholder_sanity",
            "shuffle_control_center_colors",
            "shuffle_doors",
            "shuffle_gallery_paintings",
            "shuffle_letters",
            "shuffle_symbols",
            "victory_condition",
        ]

        slot_data = {
            **self.options.as_dict(*slot_options),
            "version": [self.static_logic.get_data_version(), APWORLD_VERSION],
        }

        return slot_data

    def get_filler_item_name(self) -> str:
        return "A Job Well Done"
='n77' href='#n77'>77 78 79 80 81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170







                       
                  
                  
                      
                          
                   
 



                                          

























                      







                                                                                              





















                                   

                          




            


                                        

                    



                                     




                            
                          




                      

                      
                           
                                                  
 

                          



                                
                       
                       




                     
 
                 

                          

                             


                             
 





































                                              


                                                  
#ifndef GAME_H_7D2B65AE
#define GAME_H_7D2B65AE

#include <tuple>
#include <set>
#include <random>
#include <list>
#include "map.h"
#include "muxer.h"
#include "timer.h"
#include "animation.h"
#include "interpolation.h"
#include "consts.h"

constexpr int TilesetIndex(int x, int y) {
  return x + y * 24;
}

enum class Tile {
  Floor,
  Wall,
  Dust,
  Lamp
};

enum class Source {
  None,
  Dust,
  Lamp,
  Player
};

enum class LoseState {
  None,
  PoppingLamps,
  PoppingPlayer,
  Outro
};

struct Input {
  bool left = false;
  bool right = false;
  bool up = false;
  bool down = false;

  bool operator==(const Input& rhs) const {
    return std::tie(left, right, up, down) == std::tie(rhs.left, rhs.right, rhs.up, rhs.down);
  }

  bool operator!=(const Input& rhs) const {
    return !(*this == rhs);
  }
};

using coord = std::tuple<int, int>;

struct Kickup {
  int x;
  int y;
  size_t cur;
  size_t radius;
  size_t chain;
  std::set<coord> done;
  std::set<coord> front;
};

struct MapData {
  Tile tile = Tile::Floor;
  bool lit = false;
  bool wasLit = false;
  size_t dustLife = 0;
  Source lightType = Source::None;
  int lightRadius = 0;
  std::set<coord> litTiles;
  int renderId = -1;
  bool dirtyRender = true;
};

class Game {
public:

  Game(std::mt19937& rng, Muxer& muxer);

  void update(size_t dt);

  std::mt19937& rng;
  Muxer& muxer;

  bool quit = false;
  LoseState losing = LoseState::None;

  Map<MapData> map;
  std::list<Kickup> kickups;
  int litSpots = 0;
  bool dirtyLighting = true;
  bool dirtyRender = true;
  size_t numLamps = 0;
  size_t numDust = 0;

  int player_x = 0;
  int player_y = 0;
  int player_oldx = 0;
  int player_oldy = 0;
  bool renderPlayer = true;
  Animation playerAnim {"../res/player_anim.txt"};

  int maxZoom = INIT_ZOOM;

  int curZoom = INIT_ZOOM;
  int curBoundX = map.getLeft();
  int curBoundY = map.getTop();

  bool zooming = false;
  int zoomProgress = 0;
  int zoomLength;
  int lastZoomTop;
  int lastZoomLeft;
  int lastZoomWidth;
  int lastZoomHeight;

  Input keystate;
  bool firstInput = false;
  Input lastInput;
  bool alreadyBumped = false;
  Timer bumpCooldown = {500};
  Interpolation moveProgress;
  bool moving = false;
  bool queueDash = false;

  Timer dustTimer = {40};
  Timer inputTimer = {50};
  Timer losePopLampTimer = {800};
  Timer losePopPlayerTimer = {3000};
  Timer zoomTimer = {62};

private:

  void tick(
    int x1,
    int y1,
    int x2,
    int y2,
    bool invert = false,
    bool onlyDark = false);

  void tick(bool onlyDark = false);

  bool movePlayer(int x, int y);

  void recalculateLighting();

  void recalculateRender();

  bool processKeys(const Input& keystate);

  void kickUpDust(int x, int y, size_t chain);

  void popLamp(int x, int y, size_t chain);

  void processKickup();

  void growMap(size_t zoom);

  void setZoom(size_t zoom);

  void performDash();

};

#endif /* end of include guard: GAME_H_7D2B65AE */