Skip to content

Commit

Permalink
Merge pull request #1 from FondUnicycle/1.1.2-beta
Browse files Browse the repository at this point in the history
Merging 1.1.2-beta branch
  • Loading branch information
FondUnicycle authored Oct 10, 2022
2 parents dfb3b05 + 42df1a9 commit 101b05a
Show file tree
Hide file tree
Showing 18 changed files with 836 additions and 157 deletions.
3 changes: 0 additions & 3 deletions Bingo[BP]/functions/player_join.mcfunction

This file was deleted.

5 changes: 0 additions & 5 deletions Bingo[BP]/functions/tick.json

This file was deleted.

23 changes: 23 additions & 0 deletions Bingo[BP]/items/info_book.item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"format_version": "1.16.100",
"minecraft:item": {
"description": {
"identifier": "fond:info_book",
"category": "commands"
},
"components": {
"minecraft:max_stack_size": 1,
"minecraft:display_name": {
"value": "item.fond:info_book.name"
},
"minecraft:icon": {
"texture": "book_portfolio"
},
"minecraft:cooldown": {
"category": "card",
"duration": 1
}
},
"events": {}
}
}
30 changes: 0 additions & 30 deletions Bingo[BP]/loot_tables/info_book.json

This file was deleted.

24 changes: 15 additions & 9 deletions Bingo[BP]/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,43 @@
"authors": [ "FondUnicycle" ]
},
"header": {
"name": "Bedrock Bingo",
"name": "Bedrock Bingo 1.1.2 for 1.19.31",
"description": "Play Bingo in Minecraft\n§oMade by§r §l§9FondUnicycle",
"uuid": "5ad6d6a8-c46f-4d95-a681-21b65caedf5c",
"version": [ 1, 0, 0 ],
"min_engine_version": [ 1, 18, 10 ]
"version": [ 1, 1, 2 ],
"min_engine_version": [ 1, 19, 31 ]
},
"modules": [
{
"description": "Behaviors",
"type": "data",
"uuid": "d8d2d351-efb8-40e7-ba7d-96e7d66e66f1",
"version": [ 1, 0, 0 ]
"version": [ 1, 1, 2 ]
},
{
"description": "Scripts",
"type": "javascript",
"language": "javascript",
"type": "script",
"entry": "scripts/main.js",
"uuid": "9952c1d0-55e5-4d52-9cff-5faea4620f98",
"version": [ 1, 0, 0 ]
"version": [ 1, 1, 2 ]
}
],
"dependencies": [
{
// Resource Pack
"uuid": "f01c794a-cd2f-46b1-a31e-eaa7548dcdf2",
"version": [ 1, 0, 0 ]
"version": [ 1, 1, 2 ]
},
{
// mojang-minecraft Module
"uuid": "b26a4d4c-afdf-4690-88f8-931846312678",
"version": [ 0, 1, 0 ]
"version": "1.0.0-beta"
},
{
// mojang-minecraft-ui
"uuid": "2bd50a27-ab5f-4f40-a596-3641627c635e",
"version": "1.0.0-beta"
}
]
}
}
149 changes: 129 additions & 20 deletions Bingo[BP]/scripts/card.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,63 @@
import { emoji_ids, cardMarker } from './emoji_ids.js';
import { createItemList } from './difficulties.js';
import { SETTINGS } from './ui_screens.js'

export const CardRows = 5;
export const CardCols = 5;

const keys = Object.keys(emoji_ids);
let itemList = createItemList(SETTINGS.difficulty);

const maxBeds = 1;
const maxCandles = 1;
const maxDyes = 2;
const maxNetherite = 1;
const maxDiamond = 2
const maxGold = 2;
const maxIron = 3;
const maxLeather = 2;
const maxChainmail = 1;
const maxBoats = 1;
const maxDoors = 1;
const maxSigns = 1;
const maxFlowers = 2;


export function setCardDifficulty() {
itemList = createItemList(SETTINGS.difficulty);
};

export class Card {
constructor(player){
this.player = player;
this.itemGrid = this.genCard();
this.rawtextObj = { "rawtext": [] };
this.isDisplaying = false;
this.bedCounter = maxBeds;
this.candleCounter = maxCandles;

this.bedCounter;
this.candleCounter;
this.dyeCounter;
this.netheriteCounter;
this.diamondCounter;
this.goldCounter;
this.ironCounter;
this.leatherCounter;
this.chainmailCounter;
this.boatCounter;
this.doorCounter;
this.signCounter;
this.flowerCounter;
}

genCard() {
this.resetCounters();
const selections = new Set();
let randomKey;
let item;
do {
randomKey = keys[Math.floor(Math.random() * keys.length)];
randomKey = itemList[Math.floor(Math.random() * itemList.length)];
item = emoji_ids[randomKey];
if (item?.id == 'minecraft:bed') {
if (this.bedCounter < 0) {
selections.add(randomKey);
this.bedCounter--;
}
}
else if (item.toString().endsWith('candle')) {
if (this.candleCounter < 0) {
selections.add(randomKey);
this.candleCounter--;
}
}
else {

if(this.canAddItem(item)) {
selections.add(randomKey);
}
} while (selections.size < CardRows*CardCols);
Expand All @@ -48,14 +68,101 @@ export class Card {
result[r] = new Array(CardCols);
for (let c = 0; c < result[r].length; c++) {
result[r][c] = setIter.next().value;
//this.player.runCommand(`say ${JSON.stringify(emoji_ids[result[r][c]])}`);
}
}
return result;
}

resetCounters(){
this.bedCounter = maxBeds;
this.candleCounter = maxCandles;
return result;
this.dyeCounter = maxDyes;
this.netheriteCounter = maxNetherite;
this.diamondCounter = maxDiamond;
this.goldCounter = maxGold;
this.ironCounter = maxIron;
this.leatherCounter = maxLeather;
this.chainmailCounter = maxChainmail;
this.bedCounter = maxBoats;
this.doorCounter = maxDoors;
this.signCounter = maxSigns;
this.flowerCounter = maxFlowers;
}

canAddItem(item) {
if (item?.id == 'minecraft:bed') {
if (this.bedCounter == 0) return false;
this.bedCounter--;
return true;
}
else if (item.toString().includes('candle')) {
if (this.candleCounter == 0) return false;
if(Math.random() < 0.5){
this.candleCounter--;
return true;
}
return false;
}
else if (item.toString().includes('netherite') || item.toString().includes('debris')) {
if (this.netheriteCounter == 0) return false;
this.netheriteCounter--;
return true;
}
else if (item.toString().includes('diamond')) {
if (this.diamondCounter == 0) return false;
this.diamondCounter--;
return true;
}
else if (item.toString().includes('gold') || item.toString().includes('golden')) {
if (this.goldCounter == 0) return false;
this.goldCounter--;
return true;
}
else if (item.toString().includes('iron')) {
if(this.ironCounter == 0) return false;
this.ironCounter--;
return true;
}
else if (item.toString().includes('leather')) {
if(this.leatherCounter == 0) return false;
this.leatherCounter--;
return true;
}
else if (item.toString().includes('chainmail')) {
if(this.chainmailCounter == 0) return false;
this.chainmailCounter--;
return true;
}
else if (item.toString().includes('boat')) {
if(this.boatCounter == 0) return false;
this.boatCounter--;
return true;
}
else if (item.toString().includes('door')) {
if(this.doorCounter == 0) return false;
this.doorCounter--;
return true;
}
else if (item.toString().includes('sign')) {
if(this.signCounter == 0) return false;
this.signCounter--;
return true;
}
else if (item.toString().includes('dye')) {
if(this.dyeCounter == 0) return false;
this.dyeCounter--;
return true;
}
else if (item?.id?.toString()?.includes('flower') || item?.id?.toString()?.includes('plant')) {
if(this.flowerCounter == 0) return false;
this.flowerCounter--;
return true;
}
else {
return true;
}
}

cardToText() {
this.rawtextObj.rawtext[0] = {"text":"§b§c§r"};
let element;
Expand All @@ -67,6 +174,8 @@ export class Card {
text = { "text": `${textOfRow}`};
this.rawtextObj.rawtext[r+1] = text;
}
// Full String length: 146 chars
// {"rawtext":[{"text":"§b§c§r"},{"text":"00000\n\n\n"},{"text":"00000\n\n\n"},{"text":"00000\n\n\n"},{"text":"00000\n\n\n"},{"text":"00000\n\n\n"}]}
}

display(show) {
Expand All @@ -86,4 +195,4 @@ export class Card {
this.cardToText();
this.display(this.isDisplaying);
}
}
}
Loading

0 comments on commit 101b05a

Please sign in to comment.