mirror of
https://github.com/He4eT/DotDashPit.git
synced 2026-05-04 17:37:23 +00:00
es3: add polyfills and scripts
This commit is contained in:
parent
4da7646bb4
commit
e11a3fc4e5
3 changed files with 46 additions and 0 deletions
6
Makefile
6
Makefile
|
|
@ -38,4 +38,10 @@ import_cover:
|
||||||
${tic_cli} \
|
${tic_cli} \
|
||||||
'load ${game_src} & import screen ${cover_src} & exit'
|
'load ${game_src} & import screen ${cover_src} & exit'
|
||||||
|
|
||||||
|
build_es3:
|
||||||
|
npm run build
|
||||||
|
./polyfills/inject.sh
|
||||||
|
@make release
|
||||||
|
git restore ${game_src}
|
||||||
|
|
||||||
# vim: set ts=4 sw=4 autoindent noexpandtab:
|
# vim: set ts=4 sw=4 autoindent noexpandtab:
|
||||||
|
|
|
||||||
10
polyfills/inject.sh
Executable file
10
polyfills/inject.sh
Executable file
|
|
@ -0,0 +1,10 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
POLYFILLS_FILE="./polyfills/polyfills.js"
|
||||||
|
GAME_FILE="game.js"
|
||||||
|
TEMP_FILE="merged_game.js"
|
||||||
|
|
||||||
|
sed -i 's/TIC()/_()/' "$GAME_FILE"
|
||||||
|
|
||||||
|
cat "$POLYFILLS_FILE" "$GAME_FILE" > "$TEMP_FILE"
|
||||||
|
mv "$TEMP_FILE" "$GAME_FILE"
|
||||||
30
polyfills/polyfills.js
Normal file
30
polyfills/polyfills.js
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
// script: js
|
||||||
|
function TIC() {
|
||||||
|
gameScreens[currentScreen]()
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.fromEntries = function (entries) {
|
||||||
|
var obj = {}
|
||||||
|
for (var i = 0; i < entries.length; i++) {
|
||||||
|
var entry = entries[i]
|
||||||
|
var key = entry[0]
|
||||||
|
var value = entry[1]
|
||||||
|
obj[key] = value
|
||||||
|
}
|
||||||
|
return obj
|
||||||
|
}
|
||||||
|
|
||||||
|
String.prototype.padStart = function padStart(targetLength, padString) {
|
||||||
|
padString = typeof padString !== 'undefined' ? String(padString) : ' '
|
||||||
|
var str = String(this)
|
||||||
|
if (str.length >= targetLength) {
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
var padding = ''
|
||||||
|
var padLength = targetLength - str.length
|
||||||
|
while (padding.length < padLength) {
|
||||||
|
padding += padString
|
||||||
|
}
|
||||||
|
padding = padding.slice(0, padLength)
|
||||||
|
return padding + str
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue