mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-08-04 04:43:57 +00:00
written createMov in an OOP way
This commit is contained in:
parent
b698c8a8a1
commit
8d18946450
@ -758,6 +758,28 @@ struct hrmap_archimedean : hrmap {
|
|||||||
return -t1.first;
|
return -t1.first;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void find_cell_connection(cell *c, int d) override {
|
||||||
|
if(PURE) {
|
||||||
|
if(arcm::id_of(c->master) < arcm::current.N * 2) {
|
||||||
|
heptspin hs = heptspin(c->master, d) + wstep + 2 + wstep + 1;
|
||||||
|
c->c.connect(d, hs.at->c7, hs.spin, hs.mirrored);
|
||||||
|
}
|
||||||
|
else c->c.connect(d, c, d, false);
|
||||||
|
}
|
||||||
|
else if(DUAL) {
|
||||||
|
if(arcm::id_of(c->master) >= arcm::current.N * 2) {
|
||||||
|
heptagon *h2 = createStep(c->master, d*2);
|
||||||
|
int d1 = c->master->c.spin(d*2);
|
||||||
|
c->c.connect(d, h2->c7, d1/2, false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("bad connection\n");
|
||||||
|
c->c.connect(d,c,d,false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else hrmap::find_cell_connection(c, d);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
EX hrmap *new_map() { return new hrmap_archimedean; }
|
EX hrmap *new_map() { return new hrmap_archimedean; }
|
||||||
|
65
cell.cpp
65
cell.cpp
@ -59,6 +59,8 @@ struct hrmap {
|
|||||||
virtual transmatrix spin_from(cell *c, int d, ld bonus=0);
|
virtual transmatrix spin_from(cell *c, int d, ld bonus=0);
|
||||||
|
|
||||||
virtual double spacedist(cell *c, int i) { return hdist0(tC0(adj(c, i))); }
|
virtual double spacedist(cell *c, int i) { return hdist0(tC0(adj(c, i))); }
|
||||||
|
|
||||||
|
virtual void find_cell_connection(cell *c, int d);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** hrmaps which are based on regular non-Euclidean 2D tilings, possibly quotient
|
/** hrmaps which are based on regular non-Euclidean 2D tilings, possibly quotient
|
||||||
@ -75,6 +77,7 @@ struct hrmap_standard : hrmap {
|
|||||||
transmatrix adj(heptagon *h, int d) override;
|
transmatrix adj(heptagon *h, int d) override;
|
||||||
ld spin_angle(cell *c, int d) override;
|
ld spin_angle(cell *c, int d) override;
|
||||||
double spacedist(cell *c, int i) override;
|
double spacedist(cell *c, int i) override;
|
||||||
|
void find_cell_connection(cell *c, int d) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
void clearfrom(heptagon*);
|
void clearfrom(heptagon*);
|
||||||
@ -192,24 +195,15 @@ hrmap_hyperbolic::hrmap_hyperbolic(heptagon *o) { origin = o; }
|
|||||||
|
|
||||||
hrmap_hyperbolic::hrmap_hyperbolic() { origin = hyperbolic_origin(); }
|
hrmap_hyperbolic::hrmap_hyperbolic() { origin = hyperbolic_origin(); }
|
||||||
|
|
||||||
/** very similar to createMove in heptagon.cpp */
|
void hrmap::find_cell_connection(cell *c, int d) {
|
||||||
EX cell *createMov(cell *c, int d) {
|
heptagon *h2 = createStep(c->master, d);
|
||||||
if(d<0 || d>= c->type) {
|
c->c.connect(d, h2->c7,c->master->c.spin(d), c->master->c.mirror(d));
|
||||||
printf("ERROR createmov\n");
|
hybrid::link();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(c->move(d)) return c->move(d);
|
void hrmap_standard::find_cell_connection(cell *c, int d) {
|
||||||
else if(hybri)
|
|
||||||
hybrid::find_cell_connection(c, d);
|
|
||||||
#if CAP_BT
|
|
||||||
else if(kite::in())
|
|
||||||
kite::find_cell_connection(c, d);
|
|
||||||
#endif
|
|
||||||
else if(fake::in()) {
|
|
||||||
return FPIU(createMov(c, d));
|
|
||||||
}
|
|
||||||
#if CAP_IRR
|
#if CAP_IRR
|
||||||
else if(IRREGULAR) {
|
if(IRREGULAR) {
|
||||||
irr::link_cell(c, d);
|
irr::link_cell(c, d);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -223,33 +217,11 @@ EX cell *createMov(cell *c, int d) {
|
|||||||
hybrid::link();
|
hybrid::link();
|
||||||
}
|
}
|
||||||
else if(INVERSE) {
|
else if(INVERSE) {
|
||||||
return gp::inverse_move(c, d);
|
gp::inverse_move(c, d);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if CAP_ARCM
|
else if(PURE) {
|
||||||
else if(arcm::in() && PURE) {
|
hrmap::find_cell_connection(c, d);
|
||||||
if(arcm::id_of(c->master) < arcm::current.N * 2) {
|
|
||||||
heptspin hs = heptspin(c->master, d) + wstep + 2 + wstep + 1;
|
|
||||||
c->c.connect(d, hs.at->c7, hs.spin, hs.mirrored);
|
|
||||||
}
|
|
||||||
else c->c.connect(d, c, d, false);
|
|
||||||
}
|
|
||||||
else if(arcm::in() && DUAL) {
|
|
||||||
if(arcm::id_of(c->master) >= arcm::current.N * 2) {
|
|
||||||
heptagon *h2 = createStep(c->master, d*2);
|
|
||||||
int d1 = c->master->c.spin(d*2);
|
|
||||||
c->c.connect(d, h2->c7, d1/2, false);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
printf("bad connection\n");
|
|
||||||
c->c.connect(d,c,d,false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
else if(arcm::in() || PURE) {
|
|
||||||
heptagon *h2 = createStep(c->master, d);
|
|
||||||
c->c.connect(d, h2->c7,c->master->c.spin(d), c->master->c.mirror(d));
|
|
||||||
hybrid::link();
|
|
||||||
}
|
}
|
||||||
else if(c == c->master->c7) {
|
else if(c == c->master->c7) {
|
||||||
|
|
||||||
@ -276,7 +248,16 @@ EX cell *createMov(cell *c, int d) {
|
|||||||
cellwalker cw2 = cw - 1 + wstep - 1 + wstep - 1;
|
cellwalker cw2 = cw - 1 + wstep - 1 + wstep - 1;
|
||||||
c->c.connect(d, cw2);
|
c->c.connect(d, cw2);
|
||||||
hybrid::link();
|
hybrid::link();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** very similar to createMove in heptagon.cpp */
|
||||||
|
EX cell *createMov(cell *c, int d) {
|
||||||
|
if(d<0 || d>= c->type) {
|
||||||
|
printf("ERROR createmov\n");
|
||||||
|
}
|
||||||
|
if(c->move(d)) return c->move(d);
|
||||||
|
currentmap->find_cell_connection(c, d);
|
||||||
return c->move(d);
|
return c->move(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
fake.cpp
4
fake.cpp
@ -63,6 +63,10 @@ EX namespace fake {
|
|||||||
if(currentmap == u) currentmap = this;
|
if(currentmap == u) currentmap = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void find_cell_connection(cell *c, int d) override {
|
||||||
|
FPIU(createMov(c, d));
|
||||||
|
}
|
||||||
|
|
||||||
hrmap_fake() {
|
hrmap_fake() {
|
||||||
in_underlying([this] { initcells(); underlying_map = currentmap; });
|
in_underlying([this] { initcells(); underlying_map = currentmap; });
|
||||||
for(hrmap*& m: allmaps) if(m == underlying_map) m = NULL;
|
for(hrmap*& m: allmaps) if(m == underlying_map) m = NULL;
|
||||||
|
4
kite.cpp
4
kite.cpp
@ -148,6 +148,10 @@ struct hrmap_kite : hrmap {
|
|||||||
|
|
||||||
heptagon *getOrigin() override { return origin; }
|
heptagon *getOrigin() override { return origin; }
|
||||||
|
|
||||||
|
void find_cell_connection(cell *c, int d) override {
|
||||||
|
kite::find_cell_connection(c, d);
|
||||||
|
}
|
||||||
|
|
||||||
heptagon *newtile(pshape s, int dist) {
|
heptagon *newtile(pshape s, int dist) {
|
||||||
heptagon *h = tailored_alloc<heptagon> (8);
|
heptagon *h = tailored_alloc<heptagon> (8);
|
||||||
h->s = hstate(s);
|
h->s = hstate(s);
|
||||||
|
@ -1271,6 +1271,10 @@ EX namespace hybrid {
|
|||||||
in_underlying([] { delete currentmap; });
|
in_underlying([] { delete currentmap; });
|
||||||
for(auto& p: at) destroy_cell(p.second);
|
for(auto& p: at) destroy_cell(p.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void find_cell_connection(cell *c, int d) override {
|
||||||
|
hybrid::find_cell_connection(c, d);
|
||||||
|
}
|
||||||
|
|
||||||
virtual transmatrix spin_to(cell *c, int d, ld bonus) override { if(d >= c->type-2) return Id; c = get_where(c).first; return in_underlying([&] { return currentmap->spin_to(c, d, bonus); }); }
|
virtual transmatrix spin_to(cell *c, int d, ld bonus) override { if(d >= c->type-2) return Id; c = get_where(c).first; return in_underlying([&] { return currentmap->spin_to(c, d, bonus); }); }
|
||||||
virtual transmatrix spin_from(cell *c, int d, ld bonus) override { if(d >= c->type-2) return Id; c = get_where(c).first; return in_underlying([&] { return currentmap->spin_from(c, d, bonus); }); }
|
virtual transmatrix spin_from(cell *c, int d, ld bonus) override { if(d >= c->type-2) return Id; c = get_where(c).first; return in_underlying([&] { return currentmap->spin_from(c, d, bonus); }); }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user