Skip to content

Commit

Permalink
feat: Add Coil monetization and disable/enable NEAR Level button
Browse files Browse the repository at this point in the history
  • Loading branch information
johnedvard committed Aug 30, 2022
1 parent c173470 commit e11a66e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/gameEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ export const START_NEXT_LEVEL = 'snl';
export const ARCADIAN_HEAD_SELECTED = 'ahs';
export const NEAR_TOKENS_ADDED = 'n';
export const NFT_MINT = 'nm';
export const MONETIZATION_PROGRESS = 'mp';
3 changes: 2 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta charset="utf-8" />
<title>Skeleton rope</title>
<script type="module" src="index.js"></script>
<meta name="monetization" content="$ilp.uphold.com/Wb3kd4Jf3642" />
</head>
<body>
<div id="container">
Expand All @@ -13,7 +14,7 @@
</div>
<div id="main" class="overlay">
<button id="loginoutBtn">Loading....</button>
<button id="nearLevelBtn">NEAR Levels</button>
<button id="nearLevelBtn" disabled>NEAR Levels</button>
<button id="levelBtn">Select Level</button>
<button id="bonusBtn">Bonus Content</button>
</div>
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import {
} from './near/nearConnection';
import { initMenu } from './menu';
import { setNftTokens } from './store';
import { initMonetization } from './monetization';

const init = () => {
addStyles();
new Game();
initNear();
initMenu();
initMonetization();
};

const addStyles = () => {
Expand Down
13 changes: 13 additions & 0 deletions src/monetization.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { MONETIZATION_PROGRESS } from './gameEvents';

export const initMonetization = () => {
if (document && document.monetization) {
document.monetization.addEventListener('monetizationprogress', (evt) =>
emit(MONETIZATION_PROGRESS, evt)
);
} else {
window.addEventListener('monetizationprogress', (evt) =>
emit(MONETIZATION_PROGRESS, evt)
);
}
};
2 changes: 2 additions & 0 deletions src/near/nearLogin.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export const initLoginLogout = (nearConnection) => {
nearConnection.walletConnection.isSignedIn()
) {
loginoutEl.innerHTML = 'Logout from NEAR wallet';
const nearLevelBtn = document.getElementById('nearLevelBtn');
nearLevelBtn.removeAttribute('disabled');
} else {
loginoutEl.innerHTML = 'Login to NEAR wallet';
}
Expand Down

0 comments on commit e11a66e

Please sign in to comment.