mirror of
https://github.com/asphyxia-core/plugins.git
synced 2026-03-21 17:34:46 -05:00
Added experimental 'Shared Favorite Songs' option.
This commit is contained in:
parent
90651282c0
commit
4a8e0707f0
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -11,3 +11,4 @@ package.json
|
|||
package-lock.json
|
||||
typedoc.json
|
||||
tsconfig.json
|
||||
gitadora@asphyxia/data/mdb/blacklist.txt
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
GITADORA Plugin for Asphyxia-Core
|
||||
=================================
|
||||

|
||||

|
||||
|
||||
This plugin is based on converted from public-exported Asphyxia's Routes.
|
||||
|
||||
|
|
@ -20,17 +20,19 @@ The folder structure between v1.0 and v1.1 is quite different. Do not overwrite
|
|||
2. Ctrl-C and Ctrl-V the newest version of `gitadora@asphyxia`
|
||||
3. (Custom MDB Users) Reupload MDB or move `data/custom_mdb.xml` to `data/mdb/custom.xml`
|
||||
|
||||
|
||||
Known Issues
|
||||
============
|
||||
* ~Information dialog keep showing as plugin doesn't store item data currently.~ (Fixed as of version 1.2.1)
|
||||
* Special Premium Encore on Nextage
|
||||
- Bandage solution is implemented. Try it.
|
||||
* Special Premium Encore on Nextage is unimplemented. However, a workaround is available. Try it.
|
||||
* Friends and Rivals are unimplemented.
|
||||
|
||||
Release Notes
|
||||
=============
|
||||
|
||||
v1.3.0
|
||||
----------------
|
||||
* Added experimental 'Shared Favorite Songs' option. If disabled, players will be able to keep separate lists of favorite songs for each version of Gitadora, as well as between Guitar Freaks and Drummania. Enable this option to have a single unified list of favorite songs for both games, and across all versions. Default is false, to match original arcade behaviour.
|
||||
|
||||
v1.2.3
|
||||
----------------
|
||||
* Fixed bug preventing MDB files in XML format from loading (Thanks to DualEdge for reporting this ).
|
||||
|
|
@ -47,7 +49,7 @@ v1.2.1
|
|||
* Secret Music (unlocked songs) are now saved and loaded correctly. Partially fixes Github issue #34. Note that all songs are already marked as unlocked by the server - there is no need to unlock them manually. If you would like to lock them, consider using a custom MDB.
|
||||
* Rewards field is now saved and loaded correctly. Fixes Github issue #34
|
||||
|
||||
NOTE: Rewards and secret music is saved at the end of each session, so you will see the unlock notifications one last time after updating the plugin to this version.
|
||||
NOTE: Rewards and secret music data is saved at the end of each session, so you will see the unlock notifications one last time after updating the plugin to this version.
|
||||
|
||||
v1.2.0
|
||||
----------------
|
||||
|
|
|
|||
93
gitadora@asphyxia/handlers/FavoriteMusic.ts
Normal file
93
gitadora@asphyxia/handlers/FavoriteMusic.ts
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
import { Extra } from "../models/extra";
|
||||
import { FavoriteMusic } from "../models/favoritemusic";
|
||||
import { isSharedFavoriteMusicEnabled } from "../utils";
|
||||
import Logger from "../utils/logger";
|
||||
|
||||
const logger = new Logger("FavoriteMusic");
|
||||
|
||||
/**
|
||||
* Extracts favorite music data from the given extra data container, and saves it to the database as shared favorite music data for the player with the given refid.
|
||||
* This function has no effect if the 'Shared favorite music' option is not enabled.
|
||||
* Note that shared favorite music is shared across both Guitar Freaks and Drummania, as well as all supported versions of the game.
|
||||
* @param refid The refid of the player.
|
||||
* @param extra The extra data container of the player, containing the favorite music lists to be saved.
|
||||
* @returns {boolean} - whether the favorite music data was successfully saved.
|
||||
*/
|
||||
export async function saveSharedFavoriteMusicFromExtra(refid: string, extra: Extra) : Promise<boolean>
|
||||
{
|
||||
if (!isSharedFavoriteMusicEnabled()) {
|
||||
return false
|
||||
}
|
||||
|
||||
let result : FavoriteMusic = {
|
||||
collection: 'favoritemusic',
|
||||
pluginVer: 1,
|
||||
list_1: extra.list_1,
|
||||
list_2: extra.list_2,
|
||||
list_3: extra.list_3,
|
||||
recommend_musicid_list: extra.recommend_musicid_list,
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
await saveFavoriteMusic(refid, result)
|
||||
logger.debugInfo(`Saved shared favorite music for profile ${refid} successfully.`);
|
||||
return true
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
logger.error(`Failed to save shared favorite music for profile ${refid}.`);
|
||||
logger.error(e);
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves shared favorite music data from the database for the player with the given refid, and applies the data to the provided extra data container.
|
||||
* This function has no effect if the 'Shared favorite music' option is not enabled.
|
||||
* Note that shared favorite music is shared across both Guitar Freaks and Drummania, as well as all supported versions of the game.
|
||||
* @param refid - The refid of the player.
|
||||
* @param extra - The destination object where favorite music data should be applied.
|
||||
*/
|
||||
export async function applySharedFavoriteMusicToExtra(refid : string, extra : Extra) : Promise<void>
|
||||
{
|
||||
if (!isSharedFavoriteMusicEnabled()) {
|
||||
return
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
let favoriteMusic = await loadFavoriteMusic(refid)
|
||||
|
||||
if (favoriteMusic == null) {
|
||||
logger.debugInfo(`No shared favourite music available for profile ${refid}. Using game specific favorites. Favorites will be saved as shared favorites at the end of the game session.`);
|
||||
return
|
||||
}
|
||||
|
||||
extra.list_1 = favoriteMusic.list_1
|
||||
extra.list_2 = favoriteMusic.list_2
|
||||
extra.list_3 = favoriteMusic.list_3
|
||||
extra.recommend_musicid_list = favoriteMusic.recommend_musicid_list
|
||||
logger.debugInfo(`Loaded shared favorite music for profile ${refid} successfully.`);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
logger.error(`Failed to load shared favorite music for profile ${refid}.`);
|
||||
logger.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
export async function saveFavoriteMusic(refid: string, data : FavoriteMusic) : Promise<any>
|
||||
{
|
||||
return await DB.Upsert<FavoriteMusic>(refid, {
|
||||
collection: 'favoritemusic',
|
||||
}, data)
|
||||
}
|
||||
|
||||
export async function loadFavoriteMusic(refid : string) : Promise<FavoriteMusic>
|
||||
{
|
||||
return await DB.FindOne<FavoriteMusic>(refid, {
|
||||
collection: 'favoritemusic'
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -11,6 +11,7 @@ import { PLUGIN_VER } from "../const";
|
|||
import Logger from "../utils/logger"
|
||||
import { isAsphyxiaDebugMode } from "../Utils/index";
|
||||
import { SecretMusicEntry } from "../models/secretmusicentry";
|
||||
import { applySharedFavoriteMusicToExtra, saveSharedFavoriteMusicFromExtra } from "./FavoriteMusic";
|
||||
|
||||
const logger = new Logger("profiles")
|
||||
|
||||
|
|
@ -92,6 +93,8 @@ export const getPlayer: EPR = async (info, data, send) => {
|
|||
const profile = dm ? dmProfile : gfProfile;
|
||||
const extra = dm ? dmExtra : gfExtra;
|
||||
|
||||
await applySharedFavoriteMusicToExtra(refid, extra)
|
||||
|
||||
const record: any = {
|
||||
gf: {},
|
||||
dm: {},
|
||||
|
|
@ -820,6 +823,7 @@ export const savePlayers: EPR = async (info, data, send) => {
|
|||
}
|
||||
catch (e) {
|
||||
logger.error(e)
|
||||
logger.error(e.stack)
|
||||
return send.deny();
|
||||
}
|
||||
};
|
||||
|
|
@ -831,7 +835,7 @@ async function saveSinglePlayer(dataplayer: KDataReader, refid: string, no: numb
|
|||
const extra = await getExtra(refid, version, game) as any;
|
||||
const rec = await getRecord(refid, version, game) as any;
|
||||
|
||||
const autoSet = (field: keyof Profile, path: string, array = false): void => {
|
||||
const autoSet = function (field: keyof Profile, path: string, array = false): void {
|
||||
if (array) {
|
||||
profile[field] = dataplayer.numbers(path, profile[field])
|
||||
} else {
|
||||
|
|
@ -964,10 +968,11 @@ async function saveSinglePlayer(dataplayer: KDataReader, refid: string, no: numb
|
|||
await DB.Upsert(refid, { collection: 'extra', game, version }, extra)
|
||||
|
||||
const playedStages = dataplayer.elements('stage');
|
||||
// logStagesPlayed(playedStages)
|
||||
logStagesPlayed(playedStages)
|
||||
|
||||
const scores = await updatePlayerScoreCollection(refid, playedStages, version, game)
|
||||
await saveScore(refid, version, game, scores);
|
||||
await saveSharedFavoriteMusicFromExtra(refid, extra)
|
||||
}
|
||||
|
||||
async function updatePlayerScoreCollection(refid, playedStages, version, game) {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ const logger = new Logger("main")
|
|||
|
||||
export function register() {
|
||||
if(!isRequiredCoreVersion(1, 20)) {
|
||||
console.error("You need newer version of Core. v1.20 or newer required.")
|
||||
console.error("A newer version of Asphyxia Core (v1.20 or later) is required.")
|
||||
}
|
||||
|
||||
R.GameCode('M32');
|
||||
|
|
@ -38,10 +38,18 @@ export function register() {
|
|||
default: false,
|
||||
})
|
||||
|
||||
R.Config("shared_favorite_songs", {
|
||||
name: "Shared Favorite Songs (Experimental)",
|
||||
desc: "If disabled, players will be able to keep separate lists of favorite songs for each version of Gitadora, as well as between Guitar Freaks and Drummania. " +
|
||||
"Enable this option to have a single unified list of favorite songs for both games, and across all versions. Default is false, to match original arcade behaviour.",
|
||||
type: "boolean",
|
||||
default: false,
|
||||
})
|
||||
|
||||
R.DataFile("data/mdb/custom.xml", {
|
||||
accept: ".xml",
|
||||
name: "Custom MDB",
|
||||
desc: "You need to enable the 'Enable Custom MDB' option for the uploaded file to have any effect."
|
||||
desc: "Remember to enable the 'Enable Custom MDB' option for the uploaded file to have any effect."
|
||||
})
|
||||
|
||||
R.WebUIEvent('updatePlayerInfo', updatePlayerInfo);
|
||||
|
|
|
|||
10
gitadora@asphyxia/models/favoritemusic.ts
Normal file
10
gitadora@asphyxia/models/favoritemusic.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
export interface FavoriteMusic {
|
||||
collection: 'favoritemusic',
|
||||
|
||||
pluginVer: number;
|
||||
list_1: number[];
|
||||
list_2: number[];
|
||||
list_3: number[];
|
||||
recommend_musicid_list: number[];
|
||||
|
||||
}
|
||||
|
|
@ -18,7 +18,11 @@ export function isRequiredCoreVersion(major: number, minor: number) {
|
|||
return core_major > major || (core_major === major && core_minor >= minor)
|
||||
};
|
||||
|
||||
export function isAsphyxiaDebugMode() {
|
||||
export function isAsphyxiaDebugMode() : boolean {
|
||||
const argv = process.argv
|
||||
return argv.includes("--dev") || argv.includes("--console")
|
||||
}
|
||||
|
||||
export function isSharedFavoriteMusicEnabled() : boolean{
|
||||
return Boolean(U.GetConfig("shared_favorite_songs"))
|
||||
}
|
||||
|
|
@ -78,6 +78,18 @@ div
|
|||
label.label Excellent Full Combos
|
||||
.control
|
||||
input.input(type="text" name="exce_num", value=pr.exce_num readonly)
|
||||
.field
|
||||
label.label Highest Difficulty Cleared
|
||||
.control
|
||||
input.input(type="text" name="max_clear_diff", value=(pr.max_clear_diff/100) readonly)
|
||||
.field
|
||||
label.label Highest Difficulty Full Combo
|
||||
.control
|
||||
input.input(type="text" name="max_full_diff", value=(pr.max_full_diff/100) readonly)
|
||||
.field
|
||||
label.label Highest Difficulty Excellent Full Combo
|
||||
.control
|
||||
input.input(type="text" name="max_exce_diff", value=(pr.max_exce_diff/100) readonly)
|
||||
.field
|
||||
label.label Sessions
|
||||
.control
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user