Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
FSaurenbach authored Mar 4, 2024
1 parent 7dadf1c commit a53991a
Showing 1 changed file with 151 additions and 60 deletions.
211 changes: 151 additions & 60 deletions korge-hello-world.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@
} });
}
});
if (typeof Math.sign === "undefined") {
Math.sign = function(x2) {
x2 = +x2;
if (x2 === 0 || isNaN(x2)) {
return Number(x2);
}
return x2 > 0 ? 1 : -1;
};
}
if (typeof Math.log2 === "undefined") {
Math.log2 = function(x2) {
return Math.log(x2) * Math.LOG2E;
};
}
if (typeof Math.hypot === "undefined") {
Math.hypot = function() {
var y2 = 0;
Expand All @@ -92,25 +106,22 @@
return Math.sqrt(y2);
};
}
if (typeof Math.clz32 === "undefined") {
Math.clz32 = function(log3, LN2) {
return function(x2) {
var asUint = x2 >>> 0;
if (asUint === 0) {
return 32;
}
return 31 - (log3(asUint) / LN2 | 0) | 0;
};
}(Math.log, Math.LN2);
}
if (typeof Math.log10 === "undefined") {
Math.log10 = function(x2) {
return Math.log(x2) * Math.LOG10E;
};
}
if (typeof Math.sign === "undefined") {
Math.sign = function(x2) {
x2 = +x2;
if (x2 === 0 || isNaN(x2)) {
return Number(x2);
}
return x2 > 0 ? 1 : -1;
};
}
if (typeof Math.log2 === "undefined") {
Math.log2 = function(x2) {
return Math.log(x2) * Math.LOG2E;
};
}
if (typeof Math.trunc === "undefined") {
Math.trunc = function(x2) {
if (isNaN(x2)) {
Expand All @@ -122,17 +133,6 @@
return Math.ceil(x2);
};
}
if (typeof Math.clz32 === "undefined") {
Math.clz32 = function(log3, LN2) {
return function(x2) {
var asUint = x2 >>> 0;
if (asUint === 0) {
return 32;
}
return 31 - (log3(asUint) / LN2 | 0) | 0;
};
}(Math.log, Math.LN2);
}
if (typeof String.prototype.endsWith === "undefined") {
Object.defineProperty(String.prototype, "endsWith", { value: function(searchString, position2) {
var subjectString = this.toString();
Expand Down Expand Up @@ -269901,6 +269901,7 @@
var Enum2 = kotlin_kotlin2.$_$.ok;
var numberToInt2 = kotlin_kotlin2.$_$.vf;
var throwUninitializedPropertyAccessException2 = kotlin_kotlin2.$_$.em;
var abs2 = kotlin_kotlin2.$_$.hg;
var View2 = kotlin_com_soywiz_korge_korge.$_$.r;
var View_init_$Init$2 = kotlin_com_soywiz_korge_korge.$_$.d;
var Image_init_$Create$2 = kotlin_com_soywiz_korge_korge.$_$.c;
Expand Down Expand Up @@ -270248,6 +270249,24 @@
return blackRook;
}
var blackRook;
function set_whiteKnight(_set____db54di) {
_init_properties_Main_kt__xi25uv();
whiteKnight = _set____db54di;
}
function get_whiteKnight() {
_init_properties_Main_kt__xi25uv();
return whiteKnight;
}
var whiteKnight;
function set_blackKnight(_set____db54di) {
_init_properties_Main_kt__xi25uv();
blackKnight = _set____db54di;
}
function get_blackKnight() {
_init_properties_Main_kt__xi25uv();
return blackKnight;
}
var blackKnight;
function set_pieces(_set____db54di) {
_init_properties_Main_kt__xi25uv();
pieces = _set____db54di;
Expand Down Expand Up @@ -270322,9 +270341,15 @@
destination_0.add_utx5q5_k$(tmp$ret$3);
}
var blackPawns = destination_0;
var whiteRook2 = new Piece(PieceKind_WhiteRook_getInstance(), Colors_getInstance2().get_WHITE_2x68tz_k$(), 5, 5, $this.cont_1);
var blackRook2 = new Piece(PieceKind_BlackRook_getInstance(), Colors_getInstance2().get_BLACK_k2cofn_k$(), 3, 3, $this.cont_1);
get_pieces().addAll_4lagoh_k$(plus2(plus2(whitePawns, blackPawns), listOf2([whiteRook2, blackRook2])));
var whiteRook1 = new Piece(PieceKind_WhiteRook_getInstance(), Colors_getInstance2().get_WHITE_2x68tz_k$(), 0, 0, $this.cont_1);
var whiteRook2 = new Piece(PieceKind_WhiteRook_getInstance(), Colors_getInstance2().get_WHITE_2x68tz_k$(), 7, 0, $this.cont_1);
var blackRook1 = new Piece(PieceKind_BlackRook_getInstance(), Colors_getInstance2().get_BLACK_k2cofn_k$(), 0, 7, $this.cont_1);
var blackRook2 = new Piece(PieceKind_BlackRook_getInstance(), Colors_getInstance2().get_BLACK_k2cofn_k$(), 7, 7, $this.cont_1);
var whiteKnight1 = new Piece(PieceKind_WhiteKnight_getInstance(), Colors_getInstance2().get_WHITE_2x68tz_k$(), 1, 0, $this.cont_1);
var whiteKnight2 = new Piece(PieceKind_WhiteKnight_getInstance(), Colors_getInstance2().get_WHITE_2x68tz_k$(), 6, 0, $this.cont_1);
var blackKnight1 = new Piece(PieceKind_BlackKnight_getInstance(), Colors_getInstance2().get_BLACK_k2cofn_k$(), 1, 7, $this.cont_1);
var blackKnight2 = new Piece(PieceKind_BlackKnight_getInstance(), Colors_getInstance2().get_BLACK_k2cofn_k$(), 6, 7, $this.cont_1);
get_pieces().addAll_4lagoh_k$(plus2(plus2(whitePawns, blackPawns), listOf2([whiteRook1, whiteRook2, blackRook1, blackRook2, whiteKnight1, whiteKnight2, blackKnight1, blackKnight2])));
}
function handlePieceMovement(_this__u8e3s4, $this) {
var newPosition = { _v: null };
Expand Down Expand Up @@ -270439,7 +270464,7 @@
var tmp = this.get_state_iypx7s_k$();
switch (tmp) {
case 0:
this.set_exceptionState_fex74n_k$(7);
this.set_exceptionState_fex74n_k$(9);
var tmp_0 = this;
tmp_0.this0__1 = this.$this$Korge_1;
var tmp_1 = this;
Expand Down Expand Up @@ -270519,65 +270544,83 @@
case 5:
this.ARGUMENT18__1 = suspendResult;
set_blackRook(this.ARGUMENT18__1);
this.set_state_rjd8d0_k$(6);
suspendResult = readBitmap2(get_resourcesVfs2().get_6bo4tg_k$("w_knight.png"), VOID2, this);
if (suspendResult === get_COROUTINE_SUSPENDED2()) {
return suspendResult;
}
continue $sm;
case 6:
this.ARGUMENT19__1 = suspendResult;
set_whiteKnight(this.ARGUMENT19__1);
this.set_state_rjd8d0_k$(7);
suspendResult = readBitmap2(get_resourcesVfs2().get_6bo4tg_k$("b_knight.png"), VOID2, this);
if (suspendResult === get_COROUTINE_SUSPENDED2()) {
return suspendResult;
}
continue $sm;
case 7:
this.ARGUMENT20__1 = suspendResult;
set_blackKnight(this.ARGUMENT20__1);
var tmp_12 = this;
tmp_12.this19__1 = this.sceneContainer14__1;
tmp_12.this21__1 = this.sceneContainer14__1;
var tmp_13 = this;
tmp_13.injects20__1 = [];
tmp_13.injects22__1 = [];
var tmp_14 = this;
tmp_14.time21__1 = toDuration2(0, DurationUnit_SECONDS_getInstance2());
tmp_14.time23__1 = toDuration2(0, DurationUnit_SECONDS_getInstance2());
var tmp_15 = this;
tmp_15.transition22__1 = this.this19__1.get_defaultTransition_ir9wwd_k$();
tmp_15.transition24__1 = this.this21__1.get_defaultTransition_ir9wwd_k$();
var tmp_16 = this;
tmp_16.this23__1 = this.this19__1;
tmp_16.this25__1 = this.this21__1;
var tmp_17 = this;
tmp_17.clazz24__1 = getKClass2(GameScene);
tmp_17.clazz26__1 = getKClass2(GameScene);
var tmp_18 = this;
tmp_18.injects25__1 = this.injects20__1.slice();
tmp_18.injects27__1 = this.injects22__1.slice();
var tmp_19 = this;
tmp_19.time26__1 = this.time21__1;
tmp_19.time28__1 = this.time23__1;
var tmp_20 = this;
tmp_20.transition27__1 = this.transition22__1;
tmp_20.transition29__1 = this.transition24__1;
var tmp_21 = this;
tmp_21.remap28__1 = true;
this.sceneInjector29__1 = this.this23__1.get_views_j06d6t_k$().get_injector_r41iwz_k$().child_1kc9wc_k$().mapInstance_jnahoa_k$(getKClass2(SceneContainer2), this.this23__1).mapInstance_jnahoa_k$(getKClass2(Resources2), new Resources2(this.this23__1.get_coroutineContext_115oqo_k$(), this.this23__1.get_views_j06d6t_k$().get_globalResources_b5z86f_k$().get_root_wott0r_k$(), this.this23__1.get_views_j06d6t_k$().get_globalResources_b5z86f_k$()));
var this_1 = this.injects25__1;
tmp_21.remap30__1 = true;
this.sceneInjector31__1 = this.this25__1.get_views_j06d6t_k$().get_injector_r41iwz_k$().child_1kc9wc_k$().mapInstance_jnahoa_k$(getKClass2(SceneContainer2), this.this25__1).mapInstance_jnahoa_k$(getKClass2(Resources2), new Resources2(this.this25__1.get_coroutineContext_115oqo_k$(), this.this25__1.get_views_j06d6t_k$().get_globalResources_b5z86f_k$().get_root_wott0r_k$(), this.this25__1.get_views_j06d6t_k$().get_globalResources_b5z86f_k$()));
var this_1 = this.injects27__1;
var n = 0;
while (n < this_1.length) {
var tmp0 = n;
n = tmp0 + 1 | 0;
var inject = this_1[tmp0];
var tmp_22 = getKClassFromExpression2(inject);
this.sceneInjector29__1.mapInstance_jnahoa_k$(isInterface2(tmp_22, KClass2) ? tmp_22 : THROW_CCE2(), inject);
this.sceneInjector31__1.mapInstance_jnahoa_k$(isInterface2(tmp_22, KClass2) ? tmp_22 : THROW_CCE2(), inject);
}
var tmp_23 = this;
this.sceneInjector29__1;
tmp_23.newScene30__1 = new GameScene(this.sceneContainer14__1);
this.sceneInjector31__1;
tmp_23.newScene32__1 = new GameScene(this.sceneContainer14__1);
var this_2 = Companion_getInstance_164().get_logger_g9gejd_k$();
var level = Level_INFO_getInstance2();
if (this_2.isEnabled_481qtp_k$(level)) {
this_2.actualLog_lo63kr_k$(level, "Changing scene to... " + this.clazz24__1 + " ... " + this.newScene30__1);
this_2.actualLog_lo63kr_k$(level, "Changing scene to... " + this.clazz26__1 + " ... " + this.newScene32__1);
}
if (this.remap28__1) {
this.newScene30__1.init_7bmq0t_k$(this.sceneInjector29__1);
var tmp_24 = this.this23__1.get_views_j06d6t_k$().get_injector_r41iwz_k$();
var tmp_25 = getKClassFromExpression2(this.newScene30__1);
if (this.remap30__1) {
this.newScene32__1.init_7bmq0t_k$(this.sceneInjector31__1);
var tmp_24 = this.this25__1.get_views_j06d6t_k$().get_injector_r41iwz_k$();
var tmp_25 = getKClassFromExpression2(this.newScene32__1);
var tmp_26 = isInterface2(tmp_25, KClass2) ? tmp_25 : THROW_CCE2();
tmp_24.mapPrototype_6b3ef5_k$(tmp_26, main$slambda$lambda_0(this.sceneInjector29__1, this.sceneContainer14__1));
tmp_24.mapPrototype_6b3ef5_k$(tmp_26, main$slambda$lambda_0(this.sceneInjector31__1, this.sceneContainer14__1));
}
this.set_state_rjd8d0_k$(6);
suspendResult = this.this23__1._changeTo_minxkl_k$(this.newScene30__1, this.time26__1, this.transition27__1, this);
this.set_state_rjd8d0_k$(8);
suspendResult = this.this25__1._changeTo_minxkl_k$(this.newScene32__1, this.time28__1, this.transition29__1, this);
if (suspendResult === get_COROUTINE_SUSPENDED2()) {
return suspendResult;
}
continue $sm;
case 6:
case 8:
return Unit_getInstance2();
case 7:
case 9:
throw this.get_exception_x0n6w6_k$();
}
} catch ($p) {
var e = $p;
if (this.get_exceptionState_wflpxn_k$() === 7) {
if (this.get_exceptionState_wflpxn_k$() === 9) {
throw e;
} else {
this.set_state_rjd8d0_k$(this.get_exceptionState_wflpxn_k$());
Expand Down Expand Up @@ -270625,6 +270668,8 @@
blackPawn = null;
whiteRook = null;
blackRook = null;
whiteKnight = null;
blackKnight = null;
pieces = ArrayList_init_$Create$_02();
whiteTurn = true;
markedCells = ArrayList_init_$Create$_02();
Expand All @@ -270634,8 +270679,10 @@
var PieceKind_BlackPawn_instance;
var PieceKind_WhiteRook_instance;
var PieceKind_BlackRook_instance;
var PieceKind_WhiteKnight_instance;
var PieceKind_BlackKnight_instance;
function values2() {
return [PieceKind_WhitePawn_getInstance(), PieceKind_BlackPawn_getInstance(), PieceKind_WhiteRook_getInstance(), PieceKind_BlackRook_getInstance()];
return [PieceKind_WhitePawn_getInstance(), PieceKind_BlackPawn_getInstance(), PieceKind_WhiteRook_getInstance(), PieceKind_BlackRook_getInstance(), PieceKind_WhiteKnight_getInstance(), PieceKind_BlackKnight_getInstance()];
}
function valueOf2(value) {
switch (value) {
Expand All @@ -270647,6 +270694,10 @@
return PieceKind_WhiteRook_getInstance();
case "BlackRook":
return PieceKind_BlackRook_getInstance();
case "WhiteKnight":
return PieceKind_WhiteKnight_getInstance();
case "BlackKnight":
return PieceKind_BlackKnight_getInstance();
default:
PieceKind_initEntries();
THROW_IAE2("No enum constant value.");
Expand All @@ -270667,6 +270718,8 @@
PieceKind_BlackPawn_instance = new PieceKind("BlackPawn", 1);
PieceKind_WhiteRook_instance = new PieceKind("WhiteRook", 2);
PieceKind_BlackRook_instance = new PieceKind("BlackRook", 3);
PieceKind_WhiteKnight_instance = new PieceKind("WhiteKnight", 4);
PieceKind_BlackKnight_instance = new PieceKind("BlackKnight", 5);
}
var $ENTRIES2;
function PieceKind(name2, ordinal) {
Expand Down Expand Up @@ -270816,8 +270869,32 @@
}
return false;
}
function moveKnight($this, oldPos, newPos, pieceOnNewPos, withCheck) {
var rowDiff = abs2(newPos.get_first_irdx8n_k$() - oldPos.get_first_irdx8n_k$() | 0);
var colDiff = abs2(newPos.get_second_jf7fjx_k$() - oldPos.get_second_jf7fjx_k$() | 0);
if ((rowDiff === 2 ? colDiff === 1 : false) ? true : rowDiff === 1 ? colDiff === 2 : false) {
if (pieceOnNewPos == null) {
if (withCheck) {
println2(get_whiteTurn());
set_whiteTurn(!get_whiteTurn());
println2(get_whiteTurn());
}
return true;
} else if (!(pieceOnNewPos.color_1 === $this.color_1)) {
if (withCheck) {
removePiece($this, pieceOnNewPos);
println2(get_whiteTurn());
set_whiteTurn(!get_whiteTurn());
println2(get_whiteTurn());
}
return true;
}
}
return false;
}
function removePiece($this, piece) {
get_pieces().remove_cedx0m_k$(piece);
_get_piece__cu3qzh(piece).removeFromParent_owh2k8_k$();
}
function Piece(kind, color2, cx, cy, cont) {
View_init_$Init$2(this);
Expand All @@ -270828,15 +270905,15 @@
this.pieceKind_1 = kind;
this.position_1 = get_board()[this.cx_1][this.cy_1].get_pos_18iyad_k$();
if (this.color_1 === Colors_getInstance2().get_WHITE_2x68tz_k$()) {
if (kind.equals(PieceKind_WhitePawn_getInstance()) ? true : kind.equals(PieceKind_WhiteRook_getInstance())) {
this.piece_1 = Image_init_$Create$2(kind.equals(PieceKind_WhitePawn_getInstance()) ? ensureNotNull2(get_whitePawn()) : ensureNotNull2(get_whiteRook()));
if ((kind.equals(PieceKind_WhitePawn_getInstance()) ? true : kind.equals(PieceKind_WhiteRook_getInstance())) ? true : kind.equals(PieceKind_WhiteKnight_getInstance())) {
this.piece_1 = Image_init_$Create$2(kind.equals(PieceKind_WhitePawn_getInstance()) ? ensureNotNull2(get_whitePawn()) : kind.equals(PieceKind_WhiteRook_getInstance()) ? ensureNotNull2(get_whiteRook()) : ensureNotNull2(get_whiteKnight()));
size2(_get_piece__cu3qzh(this), Size2D_init_$Create$2(64, 64));
addTo2(_get_piece__cu3qzh(this), this.cont_1);
this.moveTo_tor82s_k$(this.cx_1, this.cy_1);
}
} else {
if (kind.equals(PieceKind_BlackPawn_getInstance()) ? true : kind.equals(PieceKind_BlackRook_getInstance())) {
this.piece_1 = Image_init_$Create$2(kind.equals(PieceKind_BlackPawn_getInstance()) ? ensureNotNull2(get_blackPawn()) : ensureNotNull2(get_blackRook()));
if ((kind.equals(PieceKind_BlackPawn_getInstance()) ? true : kind.equals(PieceKind_BlackRook_getInstance())) ? true : kind.equals(PieceKind_BlackKnight_getInstance())) {
this.piece_1 = Image_init_$Create$2(kind.equals(PieceKind_BlackPawn_getInstance()) ? ensureNotNull2(get_blackPawn()) : kind.equals(PieceKind_BlackRook_getInstance()) ? ensureNotNull2(get_blackRook()) : ensureNotNull2(get_blackKnight()));
size2(_get_piece__cu3qzh(this), Size2D_init_$Create$2(64, 64));
addTo2(_get_piece__cu3qzh(this), this.cont_1);
this.moveTo_tor82s_k$(this.cx_1, this.cy_1);
Expand Down Expand Up @@ -270886,6 +270963,9 @@
case 2:
tmp = moveWhiteRook(this, oldPos, newPos, pieceOnNewPos, withCheck);
break;
case 4:
tmp = moveKnight(this, oldPos, newPos, pieceOnNewPos, withCheck);
break;
default:
tmp = false;
break;
Expand All @@ -270898,6 +270978,9 @@
case 3:
tmp = moveBlackRook(this, oldPos, newPos, pieceOnNewPos, withCheck);
break;
case 5:
tmp = moveKnight(this, oldPos, newPos, pieceOnNewPos, withCheck);
break;
default:
tmp = false;
break;
Expand All @@ -270923,6 +271006,14 @@
PieceKind_initEntries();
return PieceKind_BlackRook_instance;
}
function PieceKind_WhiteKnight_getInstance() {
PieceKind_initEntries();
return PieceKind_WhiteKnight_instance;
}
function PieceKind_BlackKnight_getInstance() {
PieceKind_initEntries();
return PieceKind_BlackKnight_instance;
}
protoOf2(KR).get___file_9v20kl_k$ = get___file;
protoOf2(KR).get_bBishop_f8odkp_k$ = get_bBishop;
protoOf2(KR).get_bKing_w09y75_k$ = get_bKing;
Expand Down

0 comments on commit a53991a

Please sign in to comment.