Fixed Achievements widget layout on mobile. Minor fixes for class selector (achievement requirements now shown when selecting a locked class)
This commit is contained in:
parent
b4ffcbed2a
commit
e4d582f153
@ -545,7 +545,7 @@ def buy_weapon():
|
|||||||
|
|
||||||
@app.route('/get-available-classes', methods=['GET'])
|
@app.route('/get-available-classes', methods=['GET'])
|
||||||
def get_available_classes():
|
def get_available_classes():
|
||||||
current_user = get_current_user() # Implement this function to get the current user
|
current_user = get_current_user()
|
||||||
classes = list(classes_collection.find())
|
classes = list(classes_collection.find())
|
||||||
for class_data in classes:
|
for class_data in classes:
|
||||||
class_data['_id'] = str(class_data['_id'])
|
class_data['_id'] = str(class_data['_id'])
|
||||||
@ -560,9 +560,14 @@ def get_available_classes():
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
class_data['unlocked'] = class_data['unlocked_by_default']
|
class_data['unlocked'] = class_data['unlocked_by_default']
|
||||||
|
|
||||||
|
# Include unlock requirements for locked classes
|
||||||
|
if not class_data['unlocked']:
|
||||||
|
class_data['unlock_requirements_text'] = get_unlock_requirements_text(class_data)
|
||||||
|
|
||||||
return jsonify(classes)
|
return jsonify(classes)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/select-class', methods=['POST'])
|
@app.route('/select-class', methods=['POST'])
|
||||||
@token_required
|
@token_required
|
||||||
def select_class(current_user_id):
|
def select_class(current_user_id):
|
||||||
@ -1166,6 +1171,15 @@ def on_upgrade_selected(data):
|
|||||||
else:
|
else:
|
||||||
print(f"Error: Player ID {player_id} not found in game state")
|
print(f"Error: Player ID {player_id} not found in game state")
|
||||||
|
|
||||||
|
def get_unlock_requirements_text(class_data):
|
||||||
|
if 'unlock_requirements' in class_data:
|
||||||
|
if 'achievement' in class_data['unlock_requirements']:
|
||||||
|
achievement = achievements_collection.find_one({'id': class_data['unlock_requirements']['achievement']})
|
||||||
|
if achievement:
|
||||||
|
return f"Unlock the '{achievement['name']}' achievement"
|
||||||
|
return "Unlock requirements not specified"
|
||||||
|
|
||||||
|
|
||||||
def get_current_user():
|
def get_current_user():
|
||||||
auth_token = request.headers.get('Authorization')
|
auth_token = request.headers.get('Authorization')
|
||||||
if auth_token:
|
if auth_token:
|
||||||
|
|||||||
@ -1390,9 +1390,11 @@ function displayClassInfo(playerClass) {
|
|||||||
<p>Damage: ${playerClass.base_attributes.damage_multiplier}</p>
|
<p>Damage: ${playerClass.base_attributes.damage_multiplier}</p>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
// Add a visual indicator for locked classes in the info box
|
// Remove the locked indicator if the class is unlocked
|
||||||
if (!playerClass.unlocked_by_default) {
|
if (playerClass.unlocked) {
|
||||||
className.innerHTML += ' <span class="locked-indicator">(Locked)</span>';
|
className.innerHTML = playerClass.name;
|
||||||
|
} else {
|
||||||
|
className.innerHTML = `${playerClass.name} <span class="locked-indicator">(Locked)</span>`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3306,7 +3308,8 @@ function drawGameObjects() {
|
|||||||
|
|
||||||
function selectClass(playerClass) {
|
function selectClass(playerClass) {
|
||||||
if (!playerClass.unlocked) {
|
if (!playerClass.unlocked) {
|
||||||
notificationSystem.showNotification('This class is locked. Unlock it to select.');
|
const unlockRequirements = playerClass.unlock_requirements_text || "Unlock requirements not available";
|
||||||
|
notificationSystem.showNotification(`This class is locked. ${unlockRequirements}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1615,6 +1615,47 @@ img {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.achievements-container {
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.achievements-grid {
|
||||||
|
max-height: 40vh;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.achievement-info-box {
|
||||||
|
width: 100%;
|
||||||
|
border-left: none;
|
||||||
|
border-top: 2px solid #00ffff;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.achievement-info-box img {
|
||||||
|
width: 60px;
|
||||||
|
height: 60px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.achievement-info-box h3 {
|
||||||
|
font-size: 1.2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.achievement-info-box p {
|
||||||
|
font-size: 0.9em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.unlock-item img {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.unlock-item span {
|
||||||
|
font-size: 0.8em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Hide custom cursor for mobile devices */
|
/* Hide custom cursor for mobile devices */
|
||||||
@media (hover: none) and (pointer: coarse) {
|
@media (hover: none) and (pointer: coarse) {
|
||||||
body {
|
body {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user