-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from SK1Y101/develop
Develop
- Loading branch information
Showing
48 changed files
with
3,752 additions
and
409 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
|
||
// Define any helper functions | ||
import * as utils from "../../common/utils"; | ||
|
||
// Define this module | ||
export let TypeCalc = function(doc, settings) { | ||
|
||
// fetch the button container | ||
const moveTypeBut = doc.getElementsByClassName("move_type_button"); | ||
const typeOneBut = doc.getElementsByClassName("type_one_button"); | ||
const typeTwoBut = doc.getElementsByClassName("type_two_button"); | ||
|
||
// Fetch the text on a button | ||
const moveTypeText = doc.getElementById("move_type_text"); | ||
const typeOneText = doc.getElementById("type_one_text"); | ||
const typeTwoText = doc.getElementById("type_two_text"); | ||
|
||
// Fetch the effectiveness display | ||
const effectiveDisplay = doc.getElementById("effectiveness_display"); | ||
const effectiveText = doc.getElementById("effectiveness_display_text"); | ||
effectiveDisplay.href = "icons/effectiveness_3.png"; | ||
effectiveText.text = "Regularaly effective"; | ||
|
||
// And the actual trigger | ||
const mtb = doc.getElementById("move_type_but"); | ||
const otb = doc.getElementById("type_one_but"); | ||
const ttb = doc.getElementById("type_two_but"); | ||
utils.changeLayer(mtb, 110); | ||
utils.changeLayer(otb, 110); | ||
utils.changeLayer(ttb, 110); | ||
|
||
// the type as a number | ||
const numToType = ["Normal", "Fire", "Water", "Electric", "Grass", "Ice", "Fighting", "Poison", "Ground", "Flying", "Psychic", "Bug", "Rock", "Ghost", "Dragon", "Dark", "Steel", "Fairy"]; | ||
const effToText = ["Not effective", "Not very effective", "Regularaly effective", "Super effective"]; | ||
const numTypes = numToType.length; | ||
// store the weakness table. Row defines attacker, column defines defender | ||
const weakness = [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 2, 2, 1, 2], | ||
[2, 1, 1, 2, 4, 4, 2, 2, 2, 2, 2, 4, 1, 2, 1, 2, 4, 2], | ||
[2, 4, 1, 2, 1, 2, 2, 2, 4, 2, 2, 2, 4, 2, 1, 2, 2, 2], | ||
[2, 2, 4, 1, 1, 2, 2, 2, 0, 4, 2, 2, 2, 2, 1, 2, 2, 2], | ||
[2, 1, 4, 2, 1, 2, 2, 1, 4, 1, 2, 1, 4, 2, 1, 2, 1, 2], | ||
[2, 1, 1, 2, 4, 1, 2, 2, 4, 4, 2, 2, 2, 2, 4, 2, 1, 2], | ||
[4, 2, 2, 2, 2, 4, 2, 1, 2, 1, 1, 1, 4, 0, 2, 4, 4, 1], | ||
[2, 2, 2, 2, 4, 2, 2, 1, 1, 2, 2, 2, 1, 1, 2, 2, 0, 4], | ||
[2, 4, 2, 4, 1, 2, 2, 4, 2, 0, 2, 1, 4, 2, 2, 2, 4, 2], | ||
[2, 2, 2, 1, 4, 2, 4, 2, 2, 2, 2, 4, 1, 2, 2, 2, 1, 2], | ||
[2, 2, 2, 2, 2, 2, 4, 4, 2, 2, 1, 2, 2, 2, 2, 0, 1, 2], | ||
[2, 1, 2, 2, 4, 2, 1, 1, 2, 1, 4, 2, 2, 1, 2, 4, 1, 1], | ||
[2, 4, 2, 2, 2, 4, 1, 2, 1, 4, 2, 4, 2, 2, 2, 2, 1, 2], | ||
[0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 4, 2, 1, 2, 2], | ||
[2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 1, 0], | ||
[2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 4, 2, 2, 4, 2, 1, 2, 1], | ||
[2, 1, 1, 1, 2, 4, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 1, 4], | ||
[2, 1, 2, 2, 2, 2, 4, 1, 2, 2, 2, 2, 2, 2, 4, 4, 1, 2],]; | ||
|
||
// Fetch the selected move type | ||
var moveTypeDisplay = settings.getOrElse("MoveTypeValue", 0); | ||
var typeOneDisplay = settings.getOrElse("TypeOneValue", 0); | ||
var typeTwoDisplay = settings.getOrElse("TypeTwoValue", 0); | ||
var held = 0; | ||
|
||
// compute effectiveness | ||
let compEffect = function(move_type, type_one, type_two) { | ||
var eff_row = weakness[move_type]; | ||
return eff_row[type_one] * ((type_one == type_two) ? 2 : eff_row[type_two]); | ||
}; | ||
|
||
// change effectiveness given typings | ||
let changeEffect = function() { | ||
// fetch the weaknesses and convert to unique int | ||
var effectiveness = compEffect(moveTypeDisplay, typeOneDisplay, typeTwoDisplay); | ||
// set href based on effectiveness | ||
if (effectiveness == 16) { | ||
effectiveDisplay.href = "icons/effectiveness_5.png"; | ||
effectiveText.text = effToText[3]; | ||
} else if (effectiveness == 8 ) { | ||
effectiveDisplay.href = "icons/effectiveness_4.png"; | ||
effectiveText.text = effToText[3]; | ||
} else if (effectiveness == 4 ) { | ||
effectiveDisplay.href = "icons/effectiveness_3.png"; | ||
effectiveText.text = effToText[2]; | ||
} else if (effectiveness == 2) { | ||
effectiveDisplay.href = "icons/effectiveness_2.png"; | ||
effectiveText.text = effToText[1]; | ||
} else if (effectiveness == 1) { | ||
effectiveDisplay.href = "icons/effectiveness_1.png"; | ||
effectiveText.text = effToText[1]; | ||
} else { | ||
effectiveDisplay.href = "icons/effectiveness_0.png"; | ||
effectiveText.text = effToText[0]; | ||
}; | ||
}; | ||
|
||
// update the buttons So they show the correct type values | ||
let updateTyping = function() { | ||
// update text saved | ||
settings.replaceSettings({"MoveTypeValue":moveTypeDisplay}); | ||
settings.replaceSettings({"TypeOneValue":typeOneDisplay}); | ||
settings.replaceSettings({"TypeTwoValue":typeTwoDisplay}); | ||
// and update the display after 150 ms | ||
moveTypeText.text = numToType[moveTypeDisplay]; | ||
typeOneText.text = numToType[typeOneDisplay]; | ||
typeTwoText.text = numToType[typeTwoDisplay]; | ||
// compute the effectiveness | ||
changeEffect(); | ||
}; | ||
updateTyping(); | ||
|
||
// -----< Move Typing >----- | ||
mtb.addEventListener("mousedown", (evt) => { | ||
// start a timer | ||
held = Date.now(); | ||
// animate | ||
utils.animateElement(moveTypeBut, "select"); | ||
}); | ||
|
||
mtb.addEventListener("mouseup", (evt) => { | ||
// increment | ||
moveTypeDisplay = (moveTypeDisplay + 1 + numTypes) % numTypes; | ||
// reset if held | ||
if ((Date.now() - held) > 1000) { moveTypeDisplay = 0; }; | ||
// update the display | ||
utils.animateElement(moveTypeBut, "unselect"); updateTyping(); | ||
}); | ||
|
||
// -----< First Typing >----- | ||
otb.addEventListener("mousedown", (evt) => { | ||
// start a timer | ||
held = Date.now(); | ||
// animate | ||
utils.animateElement(typeOneBut, "select"); | ||
}); | ||
|
||
otb.addEventListener("mouseup", (evt) => { | ||
// increment | ||
typeOneDisplay = (typeOneDisplay + 1 + numTypes) % numTypes; | ||
// reset if held | ||
if ((Date.now() - held) > 1000) { typeOneDisplay = 0; }; | ||
// update the display | ||
utils.animateElement(typeOneBut, "unselect"); updateTyping(); | ||
}); | ||
|
||
// -----< Second Typing >----- | ||
ttb.addEventListener("mousedown", (evt) => { | ||
// start a timer | ||
held = Date.now(); | ||
// animate | ||
utils.animateElement(typeTwoBut, "select"); | ||
}); | ||
|
||
ttb.addEventListener("mouseup", (evt) => { | ||
// increment | ||
typeTwoDisplay = (typeTwoDisplay + 1 + numTypes) % numTypes; | ||
// reset if held | ||
if ((Date.now() - held) > 1000) { typeTwoDisplay = 0; }; | ||
// update the display | ||
utils.animateElement(typeTwoBut, "unselect"); updateTyping(); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+534 Bytes
FitbitPoketch-Export/SDK4.3/resources/buttons/Poketch_Button_bdsp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+488 Bytes
FitbitPoketch-Export/SDK4.3/resources/buttons/Poketch_Button_bdsp_shine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.05 KB
FitbitPoketch-Export/SDK4.3/resources/icons/effectiveness_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.