Coder Social home page Coder Social logo

Comments (3)

dumbmatter avatar dumbmatter commented on June 26, 2024 1

Currently I believe it uses the URL if present, and the face otherwise. No need to change that here unless that behavior is a problem. Cause if real player photos is Record<string, string | Face> then it's only one of the two that will be added - but if it's a Face you would need to delete any existing imgURL so it doesn't get overridden.

from zengm.

dumbmatter avatar dumbmatter commented on June 26, 2024

It's a good idea.

Player photos is currently (in TypeScript terms) Record<string, string> but instead it could be Record<string, string | Face>, to support either URLs or face objects, or even both mixed together. typeof x === "string" can distinguish if it's a URL (string) or a face (object).

I think basically the only part of code that'd need to change is

if (realPlayerPhotos[p.srID] !== undefined) {
p.imgURL = realPlayerPhotos[p.srID];
} else {
const name = p.name ?? `${p.firstName} ${p.lastName}`;
// Keep in sync with bbgm-rosters
const key = `dp_${p.draft.year}_${name
.replace(/ /g, "_")
.toLowerCase()}`;
if (realPlayerPhotos[key] !== undefined) {
p.imgURL = realPlayerPhotos[key];
}
}
- check if the player's photo entry is a string or an object, and then update both p.imgURL and p.face.

Please feel free to give it a shot!

from zengm.

tomkennedy22 avatar tomkennedy22 commented on June 26, 2024

Cool, I'll take a look.
Do you have an opinion on the scenario: if a player has both photo URL & and face JSON present in player profile, which to use? In the game currently, users can decide in player profiles, just wanted to see if you would prefer a default.

from zengm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.