Compare commits

..

1 Commits

Author SHA1 Message Date
OMGeeky
3c3f6f219d implement pre push hooks for checking for duplicate tilesets in maps 2023-10-15 16:21:01 +02:00
10 changed files with 56 additions and 24 deletions

View File

@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# This script will config git hook path into specific folder in your project. This script will invoked by maven build.
# @author : Mak Sophea
# @version : 1.0#
#
echo "config git hooksPath to .githooks folder for commit-msg and pre-push"
git config core.hooksPath .githooks

View File

@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# This script will config git hook path into specific folder in your project. This script will invoked by maven build.
# @author : Mak Sophea
# @version : 1.0#
#
echo "config git hooksPath to .githooks folder for commit-msg and pre-push"
git config core.hooksPath .githooks

34
.githooks/pre-push Executable file
View File

@@ -0,0 +1,34 @@
#!/usr/bin/env bash
#
# @author: OMGeeky
# @created: 2023-10-15
# @description: A script to check if a tileset is duplicated in a Tiled map.
echo "Checking for duplicate tilesets..."
# The folder to scan
folder="AndorsTrail/res/xml/*.tmx"
# The regex pattern to look for
regex='(?s)(map_\w*").*\1'
found=0
# Iterate over the files in the folder
for file in $folder; do
# If the file matches the regex pattern, print a warning and exit with a nonzero status
# echo "Checking file $file"
if grep -Pzq "$regex" "$file"; then
echo "Warning: File $file contains the regex pattern!"
found=$((found + 1))
# Print each location where the pattern is found
grep -Pzao '(?s)(map_\w*").*\1' "$file" | awk -F "\"" '{print $1; exit}'
echo ""
fi
done
if [ $found -gt 0 ]; then
echo "Duplicate tilesets found in $found files."
exit 1
else
echo "No duplicate tilesets found."
fi
# If no files matched the regex pattern, exit with a zero status
exit 0

View File

@@ -579,13 +579,6 @@ public final class CombatController implements VisualEffectCompletedCallback {
private static final int n = 50;
private static final int F = 40;
private static final float two_divided_by_PI = (float) (2f / Math.PI);
/**
* @implNote
* formula: 50 * (1 + (2 / pi) * atan((attackChance - blockChance - n) / F))
* <br/>
* n = {@value n}; F = {@value F}
* @return [0..100] . 100 == always hit.
*/
private static int getAttackHitChance(final Actor attacker, final Actor target) {
final int c = attacker.getAttackChance() - target.getBlockChance();
// (2/pi)*atan(..) will vary from -1 to +1 .

View File

@@ -1,6 +1,5 @@
package com.gpl.rpg.AndorsTrail.controller;
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
import com.gpl.rpg.AndorsTrail.context.WorldContext;
import com.gpl.rpg.AndorsTrail.controller.listeners.CombatActionListeners;
@@ -18,7 +17,6 @@ import com.gpl.rpg.AndorsTrail.model.item.ItemCategory;
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
import com.gpl.rpg.AndorsTrail.model.item.ItemTypeCollection;
import com.gpl.rpg.AndorsTrail.util.ConstRange;
import com.gpl.rpg.AndorsTrail.util.L;
public final class SkillController {
private final ControllerContext controllers;
@@ -60,9 +58,6 @@ public final class SkillController {
public static int getDropChanceRollBias(DropItem item, Player player) {
if (player == null) return 0;
if(item.itemType == null && AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES){
L.log("Item type missing: " + item + " " + player.id);
}
if (ItemTypeCollection.isGoldItemType(item.itemType.id)) {
return getRollBias(item, player, SkillID.coinfinder, SkillCollection.PER_SKILLPOINT_INCREASE_COINFINDER_CHANCE_PERCENT);

View File

@@ -137,8 +137,7 @@ public final class ResourceLoader {
final ItemTypeParser itemTypeParser = new ItemTypeParser(loader, world.actorConditionsTypes, world.itemCategories, translationLoader);
final TypedArray itemsToLoad = r.obtainTypedArray(itemsResourceId);
for (int i = 0; i < itemsToLoad.length(); ++i) {
String s = readStringFromRaw(r, itemsToLoad, i);
world.itemTypes.initialize(itemTypeParser, s);
world.itemTypes.initialize(itemTypeParser, readStringFromRaw(r, itemsToLoad, i));
}
itemsToLoad.recycle();
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) timingCheckpoint("ItemTypeParser");

View File

@@ -39,12 +39,6 @@ public final class DropListParser extends JsonCollectionParserFor<DropList> {
if (items == null) {
L.log("OPTIMIZE: Droplist \"" + droplistID + "\" has no dropped items.");
}
for (int i = 0; i < items.length; i++) {
DropItem item = items[i];
if (item.itemType == null) {
L.log("Item at index " + i + " in droplist " + droplistID + " was null");
}
}
}
return new Pair<String, DropList>(droplistID, new DropList(items));

View File

@@ -61,9 +61,13 @@ public final class TraitsInfoView {
tv.setText(Integer.toString(attackCost));
row = (TableRow) group.findViewById(R.id.traitsinfo_attack_chance_row);
tv = (TextView) group.findViewById(R.id.traitsinfo_attack_chance);
tv.setText(Integer.toString(attackChance));
if (attackChance == 0) {
row.setVisibility(View.GONE);
} else {
row.setVisibility(View.VISIBLE);
tv = (TextView) group.findViewById(R.id.traitsinfo_attack_chance);
tv.setText(Integer.toString(attackChance));
}
row = (TableRow) group.findViewById(R.id.traitsinfo_attack_damage_row);
if (damagePotential != null && damagePotential.max != 0) {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 950 KiB

After

Width:  |  Height:  |  Size: 948 KiB

View File

@@ -1 +0,0 @@
*.tmx.bak